C# 7.0 New Features – Local functions
Local functions are another very handy feature to be introduced into language if you are into code refactoring. Many a times developers create a very large method and while code review we see lot of places same logic has been repeated and thus think about refactoring it. Problem is that if the logic is required only at multiple places within same method than it’s not a good idea to make it into a separate named method.
Let’s take an example in C# 6 and then we will try to refactor that using various ways and finally with local functions feature in C# 7.0
Here is a simple code that works on array of numbers and calculates sum and subtraction of each number in array
style="display:block; text-align:center;"
data-ad-format="fluid"
data-ad-layout="in-article"
data-ad-client="ca-pub-5021110436373536"
data-ad-slot="9215486331">
Continue reading