This video show how local functions in C# 7 can be used to change the structure of the code and the visibility of a function that is only intended to be used in one place.
- [Narrator] Local functions allow us to take…a function that is only called to one place…and embedded in the function that calls it.…Here we are in the Displacement view model…and within it is a method called Get Largest Value.…The Get Largest Value method is only called…by the Get Displacement method.…Since we don't want the people modify in this code later…to try and use the get largest value method…in some other spot, we can use what's called…a local function, so what I'm going to do here…is I'm going to grab this Get Largest Value method…and I'm going to cut it and I'm going to drop it…right inside the Get Displacement method…and I'll get rid of the private keyword,…because that's no longer valid.…
The only place this Get Largest function can now be used…is within the Get Displacement method.…We are placing the local function at the end…of the containing method, but currently there's just not…seem to be a lot of restriction time where it falls.…At the start, the end or even the middle…of the containing method seem to work.…
- Working with tuples
- Using C# throw expressions
- Inspecting UI structures with Xamarin Inspector
- Identifying memory leaks in iOS and Android
- Recording and playing back tests with Test Record
- Using embedded assemblies in Android
Skill Level Intermediate
1. C# 7 Language Improvements
Inspecting UI structures3m 34s
4. Test Recorder
5. Embedded Assemblies
Where to go from here1m 54s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
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.