C# Reference - C# Access Modifiers - protected - C# Reference - C# Access Modifiers - protected
The LBTT Spot
"Lifeline is focused on developing and marketing systems designed to assist in the early detection of breast and ovarian cancer."



C# Reference - C# Access Modifiers - protected

View C# Source Code

Article Categories:

.Net Framework
.Net Framework 1.1
ADO.NET
ASP.NET
Assemblies
Asynchronous Methods
C#
Collections
Configuration
Delegates
Events
Pocket PC
Regular Expressions
Smart Devices
SQL Server
Visual C#
Visual Studio .NET
Visual Studio .NET 2003
Windows Forms
XML

C# .Net Fun Menu

View Current Page's ASP.NET Source Code
C# Reference
C# Study Flash Cards
Valuable Links
Contact Us
Site Map
Mike's Portfolio

C# Reference Search:

Full Text Search:

Articles by Author:

Code Examples (zipped):

C# Reference
      C# Access Modifiers
           protected


  • C# Access Modifiers: [protected] Reference from Microsoft®


  • Any member of a class declared as protected can be accessed ONLY within the defining class and any deriving classes.

    Structs cannot be protected because they can't be inherited.

    The protected keyword can be applied to members of a class only - not the class or other types. public class MyClass { protected String strMyString1 = "tes1t..."; private String strMyString2 = "test2..."; } public class MyClass2 : MyClass { public MyClass2() { MyClass mc = new MyClass(); // this will cause an error: String str = mc.strMyString2; String str = this.strMyString1; // this is OK // this will cause and error: String str = mc.strMyString1; } }