Error: inaccessible due to its protection level

Posted by Manikandan711 under C# on 3/6/2013 | Points: 10 | Views : 2735 | Status : [Member] | Replies : 1
HI,
I know this is a basic question but i need some depth details
Why i could not able create objects for the non static class in the static method?

Fo ex:
In this following code and getting "inaccessible due to its protection level" error ...
Please explain..


namespace dotnetfunda_ex1
{
public class ClassA
{
ClassA(int var)
{ }

public static void tm()
{ }

}

class Program
{

public static void Main(string[] args)
{
ClassA obj = new ClassA(1);
//obj.tm();

}
}


}


Manikandan Muthuraj

Thanks & Regards,
Manikandan Muthuraj
http://talkheredotnet.blogspot.com/



Responses

Posted by: Oswaldlily on: 3/8/2013 [Member] Starter | Points: 25

Up
0
Down
Static classes are sealed and so v can't create Object....


According to Your question "for the non static class in the static method? "
Non static class :both Program ,ClassA (You can create objects for these both)

Can You check your question?

Manikandan711, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response