Join Reynald Adolphe for an in-depth discussion in this video Auto-implemented properties, part of C# Best Practices for Developers.
- [Instructor] We've been using public field.…For example, for job title.…But best practice now is not to do so when there's…no logic involved.…This is why we have auto implemented properties.…For example, I'll write one for actorH,…and I can use a code snippet just called prop,…and hit tab, tab, type in my type, a string, ActorAge.…
And as of C# 6.0, we have auto property initializers.…I'll create one for ActorDescription,…a general description of the type of actor.…And the purpose of this one is it allows us…immediately to initialize it with a value,…and in this case it will be Regular actor.…
As you can see, auto implemented properties…make property declaration much more concise…when there's no additional logic that's required…in the property accessors.…That is the getters and setters.…So let's go ahead now and run a couple of tests…to see how this works.…
- Naming and handling classes
- Running a unit test
- Using constructors
- Naming and handling methods, fields, and properties
- Using properties correctly
- Managing objects efficiently
- Common design patterns as best practices
Skill Level Intermediate
1. Best Practices: An Overview
2. Naming and Handling Classes
3. Naming and Handling Methods, Fields, and Properties
4. Managing Objects Efficiently
5. More Best Practices Resources
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.