can anyone explain me about static method in c# .net with example?

I guess you havent looked in your helpfile... Make a console app, click on the wor d static, press F1 - you have an example and explaination already.

A static method belongs to the class rather than to the objects of the class.

using System;
class MyClass
{
private static int x = 20;
private static int y = 40;
public static void Method()
{
Console.WriteLine("{0},{1}",x,y);
}
}
class MyClient
{
public static void Main()
{
MyClass.Method();

}
}

if you try to call a static method from an instance method you will not be able to do this even in the intellisense it will not appear

even within the same class, a static method coudn't be called by an instance method and the inverse is true

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.