A field declared with
static modifier is called static variable. A static variable comes into
existence before execution of static constructor for its containing type, and
ceases to exist when associated application domain ceases to exist.
The initial value of
static variable is default value of the variable’s type.
Static variable can be
initialized outside the member function or class definition.
Example:-
namespace ConsoleApplication1
{
class Test
{
public static int j;
}
class Program
{
public static int i;
static void Main(string[] args)
{
Test.j
= 10;
i = 10;
}
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.