can we declare a block as static in c#?

 Posted by Ajitnayak on 2/28/2009 | Category: C# Interview questions | Views: 10945
Answer:

NO,because c# doesnot support static block,but it supports static method


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Meme on: 3/12/2012 | Points: 10
yes we can declare a static block in c#. we can access only stati c data members in this block.
syntax:
class sample
{
static int count;
public static int getcount()
{ ....
}
static {
count =getcount();
}
}

Login to post response

More Interview Questions by Ajitnayak