Static Method Vs.Non static Method:-

0
20

-A method that is by using static modifier is a static method & rest of other are non-static only.

-While defining a static method under the method, if we want to consume only non-static members we can consume them only by using object of the class whereas under non-static method ,we can consume static method directly without only restriction.

Rule :-

1.Non-static member of a class can be consumed on a static block only be using object of the class.

2.Static to Static:- can be consumed directly or with class name also.

3.Static to non- static:- can be consumed directly or class name  also.

4.Non-static to Non-static:- can be consumed directly or by using ‘this’ keyword.

Ex –

Class statements

{

Int x=100;

Static int y=200;

Static void add()

{

Statements obj=new statements();

Console.writeLine(obj.x+y);

}

Static void Main()

{

Statements. Add()

Console.ReadLine();

}

}