C# 7.0 adds a new feature called local functions, which allows local methods to be defined and called within a method. This wasn’t possible in the previous versions. The following code snippet defines a method named "Add" inside the "Main" method and calls within the "Main" method.
- static void Main(string[] args)
- {
- int Add(int a, int b)
- {
- return a + b;
- }
- Console.WriteLine(Add(3,4));
- Console.ReadKey();
- }
As its name suggests, a local function is available to the method it is defined inside only.
Summary
Local functions is a new concept introduced in C# 7.0. In this article, we learned how to write and use a local function.
Next C# 7.0 Feature - Literal Improvements in C# 7.0
References
References used to write this article,
https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/

Ammar ShaukatPosted Jun 7, 2017, 2:21 PM
Seems like they will remain useless as when it comes to their performance as compare to anonymous methods , local functions have poor performance and anonymous methods are very fast in execution.
Beyrem MakhloufPosted Jan 24, 2017, 3:11 AM
I prefer use lambda , less headache for naming
Vineet KumarPosted Jan 13, 2017, 1:18 AM
Really great and useful feature.
Pradeep RNPosted Jan 9, 2017, 7:48 AM
Thank you mahesh for your support
Pradeep RNPosted Jan 9, 2017, 6:29 AM
Ok thanks mahesh but can i get the link of github for installing c#
Pradeep RNPosted Jan 9, 2017, 12:07 AM
Hi Mahesh it is a very good feature, is c# version 7.0 available in visual studio 2013??
Rishi RautelaPosted Jan 3, 2017, 1:31 AM
Local functions are good but I didn't understand the exact reason why we need local function. We can create such functions outside and call them exactly the same way.
Manoj KallaPosted Dec 28, 2016, 12:15 AM
In C# before we have to create nested class then function... New for us ..
Damian MurrayPosted Dec 27, 2016, 4:03 PM
Pascal has had this feature for decades, glad to see C# is maturing of other languages features!
Bikesh SrivastavaPosted Dec 27, 2016, 5:44 AM
Waooo very nice its so good.
Rex HongPosted Dec 27, 2016, 1:39 AM
That's cool , I think that it is easy to read.