
What is Protected Access Modifier in C# (C Sharp)?Only the
members of a class can be marked with protected access modifier. public class
sampleClass { In this example,
protected member called member1 of sampleClass is accessed directly inside
derivedClass which inherits from sampleClass. This is acceptable because
protected members will be visible in derived classes of sampleClass. Consider
the following code below: public class
testClass { Here you
access the protected member inside a class that is not derived from sampleClass.
Hence you will end up in the following error: sampleClass.member1
is inaccessible due to protection level
_______________________________________________________________________
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 ______________________________________________________ |