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 (6)

0 answers

Post by Carl Scaglione on September 20 at 04:26:20 AM

The C# code that was in the Exercise Files was the namespace InheritableClass.  It was topically related, but no where near the same code that was delivered in the lecture. Was this intentional?  Looks like interesting code and advanced for this lesson.  Look forward to your response.

0 answers

Post by Carl Scaglione on September 20 at 04:21:57 AM

Followed along with your video and received unrecoverable compiler errors.  In your code, they did not appear and my code was almost identical.  When creating the methods 'public void Account() {}', public long Account(string name){ some code}, and public void Account (long ID, string name){}, I received the CS0542 code error:  'Account' member names cannot be the same as their enclosing type.  I did change the name of the methods to 'myAccount' and the problem went away, but the objective of the lesson was to show constructors which are supposed to have the same name as the class.  I am using Windows 10 and Visual Studio 2017.  This is new to me.  Do you have any thoughts?  I have followed your lectures and this is the first time that such an unresolvable error occurred.  

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 Lynda.com 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