[C#] Properties & Accessors Tutorial with Examples | get, set & value keywords in C#

19 Replies to “[C#] Properties & Accessors Tutorial with Examples | get, set & value keywords in C#

  1. Okay, but assuming you don't want to use any additional logic when setting or getting the property, and that you want to be able to both get and set the property, what's the difference between using a property and a normal field? Does it save the property differently in memory? I mean if I'm just gonna go and do public int myInt { get; set; } and that's it. Why would I do that instead of just public int myInt;

  2. Would you recommend using constructors with those? Probably a silly question, but just to make sure. When I learned to program, they didn't have those auto implemented properties, plus I leaned that with Java. For all I know they still don't have them. Anyway off track, just want to know about the need for constructors with those.

  3. If you are using auto implemented methods get and set (ex: int X {get;set;} ) what is the need of get and set methods. You said that they are used for range validation and to check stack overflow. But can you can't do those things using auto imported methods.

  4. Your video made me to get a complete view of getter and setter properties. I have watched many videos to get a clear idea but no one had matched with your standards even I have read MSDN but I am unable to understand because of there terminology. But you made it crystal clear and you have clarified my doubts immediately. Thank you veryyyyy much

  5. Comming from Java background so this was very helpfull, before I mostly assigned new Objects of same type with expected parameters to get by which now looks ridiculous 😀

  6. Great tutorial, but I totally fail to see the point of feature of C#? If there is no performance advantage to using this over the good old Set() and get() methods in a typical OOP design, then why in the world would this even be relevant? Slightly shorter code? Come on :/ I'd say that that slightly shorter code is absolutely not worth the overkill of having unnecessary features that will only confuse the newcomers and clog their brain with unnecessary information.

    As Einstein once said – Everything should be as simple as possible, but not simpler.
    I think features like these totally trash that logic.

    Please correct me if I'm wrong, I'm just a C# newbie after all. My primary language is Python (the greatest language in the universe! :P).

  7. this tutorial is pretty goods lots of resources can you make a more advanced tutorial about getters and setters more like ideas on how to use them ?

  8. Why are people downvoting this amazing lesson. Thank you, you helped me a ton and I love your dry humor. It's great <3

Leave a Reply

Your email address will not be published. Required fields are marked *