
What is Private Access Modifier in C# (C Sharp)?Private access
modifier provides the most restricted access. public class
sampleClass { In this example,
you have a public class called sampleClass. Member of sampleClass named
member1 is defined with private access modifier, which means that it cannot
be accessed outside the class. But you try to access it in Main method
of testClass. This is not permissible and so you will end up in the following
error during execution of this code: sampleClass.member1
is inaccessible due to protection level However,
you can display the value of private member member1 using the following
line of code: obj.displayMember1();
_______________________________________________________________________
FREE
Subscription
Subscribe
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________ |