Possible Duplicate:
Is a Java static block equivalent to a C# static constructor?
Is there an equivalent to:
public class people {
private static int x;
//...
static {
x = 3;
}
}
of JAVA in C#.NET?
Possible Duplicate:
Is a Java static block equivalent to a C# static constructor?
Is there an equivalent to:
public class people {
private static int x;
//...
static {
x = 3;
}
}
of JAVA in C#.NET?
Yeah, it looks mostly the same
public class People
{
private static int x;
static People()
{
x = 3;
}
}
but you could also do this:
public class People
{
private static int x = 3;
}
you can use a static constructor
static people()
{
x= 3;
}
see http://msdn.microsoft.com/en-us/library/k9x6w0hc(v=vs.80).aspx
or you can just initialise it as-is
private static int x = 3;