Method Nesting in C#

In this article we are going to learn about how to use nesting method in C#.
  • 3333

Introduction

Method nesting is a very interesting feature because of it reduces our programming complexity. Method Nesting is stand for a method call to another method in a same class. This is called nesting of class.

Example

class nesting
{
public void grater(int M,int n)
{
int large = max( M, n);
Console.WriteLine(large);
}
int max(int a,int b)
{
int x = (a > b) ? a : b;
return (x);
}
}
class nestTesting
{
public static void Main()
{
nesting next = new nesting();
next.grater(300, 200);
Console.ReadLine();
}
}

Output

nestingoutput.jpg

© 2020 DotNetHeaven. All rights reserved.