Join Reynald Adolphe for an in-depth discussion in this video Using static, part of C# 6.0 First Look.
- Most likely, you're already familiar with…the keyword using, to handle disposing…of objects, when dealing with a particular resource…or, to import namespaces.…We can now use using, in conjuction with static,…to import static members of types into scope.…Let me show you an example.…If we scroll down to our method, Test_UsingSimplified,…you'll notice that we refer to the static Console class,…and call the WriteLine method.…
Well, with the new version of C#,…what we can do is, actually, enter using…at the top of our file, followed by static,…and indicate System.Console,…to bring that into scope,…and you'll notice that the word Console…is now slightly faded.…That's the compiler indicating that we no longer need…to reference it and it can be simplified.…If we scroll over to the right, we also reference the Math…class, so, likewise, we can jump to the top…and also import System.Math,…and so the same thing will happen.…
So, if we click on Math,…and do ctrl + .,…the light bulb will show up and we can go ahead…and actually simplify it.…
- 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.