Hi friends,
I want to know What is static method ,static class and static variable ?
Thank you.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 8, 2012, 8:09 AM EDT
SenthilkumarRank #387 · 6.5K reputationPosted May 8, 2012, 7:23 PM EDT
The static means persists. The static methods are compile time methods and not the run time methods.
Static class:
Static Method and static variable:
The static method can be called without creating instance of the class. Normal class can have the static methods and which uses the static properties. a static class can have only static methods.
A static method, field, property, or event is callable on a class even when no instance of the class has been created. If any instances of the class are created, they cannot be used to access the static member. Only one copy of static fields and events exists, and static methods and properties can only access static fields and static events. Static members are often used to represent data or calculations that do not change in response to object state; for instance, a math library might contain static methods for calculating sine and cosine.
MuthuMari MRank #5,738 · 288 reputationPosted May 8, 2012, 10:40 PM EDT
Static variable
To declare a member variable of a class as static, type the static keyword on its left. Here is an example:
pls refer this url for samples
http://www.functionx.com/csharp/topics/staticcvariables.htm
Static methods have no instances. They are called with the type name, not an instance identifier. They are slightly faster than instance methods because of this. Static methods can be public or private. They cannot use the this instance expression.
Static ModifierKey point: Static methods are called without an instance referencepls refer this url
http://www.dotnetperls.com/static-method
thanks.