Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of C#
  • Discussion

  • Study Guides

  • Table of Contents

Lecture Comments (4)

1 answer

Last reply by: John Snape
Sun Apr 20, 2014 3:19 AM

Post by Thuy Nguyen on April 20, 2014

I learned on that the return type is not part of the method signature, because C# won't know which method you want just based on the return type.  But...somehow in this lecture you can have two constructors with the same parameter list and different return types...I don't know what is the right about overloaded methods anymore now.  

Even if you can have two methods with the same parameter type but with different return values, would it be good practice to?  

1 answer

Last reply by: John Snape
Sun Apr 20, 2014 3:09 AM

Post by Thuy Nguyen on April 20, 2014

Hi, in Java, I learned that the constructor doesn't return anything, not even void.  Why would a constructor return anything in C# if it's job is to create a new object?

Understanding & Creating Classes

  • The main parts of Classes are:
    • Fields
    • Properties
    • Constructors/Destructors
    • Events
    • Methods
  • Fields are hidden from the user of your classes, and can’t be directly modified
  • Properties are directly modifiable by your class’s users
    • They can be ReadOnly or WriteOnly
    • If you only create properties without fields backing them, Visual Basic will create fields for you, but you won’t be able to access them yourself
  • Constructors create instances of your classes, Destructors destroy instances
  • Events aren’t called directly, they are called to handle specific things that happen to your class
  • Methods are called directly to change or work with data from your class
  • You can include a Class in another project by copying it to the new project, or you can create a .dll file and reference it from another project