Posts

Showing posts with the label c# 7.0 features

C# 7 Features

Image
In this blog post we will discuss about the Local functions/methods, Ref returns and locals, Expression bodied members,Throw Exception from Expression Local Methods/Functions Now we can define local functions inside another.Ya, That's right, C# 7 version provides the ability to call a function which is defined inside another function. static void Main(string[] args) { int localvar = 50; //local function defined inside main method int LocalFunction(int a) { return localvar * a; } Console.WriteLine(LocalFunction(50)); } If we observe the code above, local function with the name "LocalFunction" is defined inside the main method and called by main method itself. This is how we can define a local function to perform a specific operation and return value to the enclosed functio...

C# 7 Features - Tuples

Image
In this blog post we are going to see the new feature called Tuple type introduced with C# 7.0 Version by Microsoft. “C# 7.0 adds a number of new features and brings a focus on data  consumption, code simplification and performance. Perhaps the biggest  features are tuples, which make it easy to have multiple results, and pattern  matching, which simplifies code that is conditional on the shape of data. But  there are many other features big and small. We hope that they all combine to  make your code more efficient and clear, and you more happy and  productive,” Mads Torgersen, program manager at Microsoft, wrote ...