shakti5385
Apr 16th, 2007, 12:59 AM
Hi all :wave:
check out the class I am using static function in it.
class sample
{
int i;
static int count = 0;
sample()
{
i = 0;
count++;
}
static void ShowCount()
{
Console.WriteLine(count);
}
}
But When I am calling the object of the class I am getting error at the underline part..class Program
{
static void Main(string[] args)
{
sample s1=new sample();//First Error
sample.ShowCount(); //Second Error
}
}
The error saying that
1)'sample.sample()' is inaccessible due to its protection level
2)'sample.ShowCount()' is inaccessible due to its protection level
So what is the problem , what I am doing wrong here.
Thanks
check out the class I am using static function in it.
class sample
{
int i;
static int count = 0;
sample()
{
i = 0;
count++;
}
static void ShowCount()
{
Console.WriteLine(count);
}
}
But When I am calling the object of the class I am getting error at the underline part..class Program
{
static void Main(string[] args)
{
sample s1=new sample();//First Error
sample.ShowCount(); //Second Error
}
}
The error saying that
1)'sample.sample()' is inaccessible due to its protection level
2)'sample.ShowCount()' is inaccessible due to its protection level
So what is the problem , what I am doing wrong here.
Thanks