Hi all,
I am new to c#. I was trying out the following:
class A
{
private static void doSomething()
{
System.Console.WriteLine("Class A is doing something");
}
}
class B
{
private static void Main()
{
A.doSomething();
}
}
If I compile the above code, I get the following error:
error CS0122: 'A.doSomething()' is inaccessible due to its
protection level
If I remove the private keyword from the method doSomething() in class A,
the file gets compiled without errors.
The error is clear to me. But what is not clear is why the compiler does not
give error for the method Main(). It is also a static method which I have
decleared private which should mean its not accessible to anybody.
Thanks in advance,
Madhu.