Join Reynald Adolphe for an in-depth discussion in this video Using index initializers, part of C# 6.0 First Look.
- You're probably familiar with object initializers…that permits you to assign values…to fields or properties of an object.…Kind of like how we just did with our artists collection.…Well Index Initializers extend object initializers…so that you can now initialize not only members…but also indices of the new objects.…Let's take a dictionary object for example,…and show the old approach and then the new approach.…
This is stand way of initializing a dictionary object.…Let's go ahead Copy and Paste this,…and modify it.…Let's change this to myNewDictionary.…So the major changes that we're going to do…is get rid of curly braces,…and then add in a bracket for Name.…Do the same for ArtistType,…and likewise for our FamousQuote.…
Then instead of a comma, we're going to use the equal sign…to assign these values.…And that's it.…While syntax wise the differences look small,…the advantage here is that we're working with indices…of the new objects indicated by the brackets.…And as a result, these initializers can be used…for any object supporting an indexer.…
- 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.