Join Reynald Adolphe for an in-depth discussion in this video Leveraging nameof expressions, part of C# 6.0 First Look.
- When refactoring, there'll be times you might want…to change the name of an identifier…like a property, a class, or variable.…And if the identifier name is referenced in a string,…Visual Studio will ignore it, just like it did here,…not changing the term thePeople to theCrowd.…And this particularly happens if you forget…to check include in strings.…And this can become a problem when you're passing…in variables' names or identifiers to an exception,…like we are here on line 29,…which will make it much more difficult to bug.…
However, even though we have the ability to change the term…by checking include strings, there's a better way…to deal with this when we're working…with properties, classes, or variables.…And that's where the nameof operator comes into play.…Nameof makes factoring a lot easier…because it makes your codes safer.…And to use it, all you need to do is type in nameof…and within parentheses, the name of the identifier.…
And now, if we try to rename this…Visual Studio takes this into account…and we can simply hit apply.…
- Introducing the new IDE in Visual Studio 2015
- Leveraging nameof expressions
- Using index initializers
- Using await in catch and finally blocks
- Using static
- Resolving conflict instance methods
Skill Level Beginner
1. Touring the Enhanced IDE
2. Expression-Level Features
3. Statement-Level Features
Adding exception filters2m 42s
4. Member Declaration and Initialization Features
5. Improved Debugging
- 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.