Access Modifiers
Hi
Iam new to .NET and iam beginning to learn it.
what are the different access modifiers used in C# and their use ?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
AdministratorRank #675 · 3.6K reputationPosted Feb 19, 2003, 8:31 AM EST
PradeepRank #6,279 · 271 reputationPosted Feb 24, 2015, 8:12 PM EST
Please reffer the link for the details
https://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx
Pradeep ShetRank #595 · 4K reputationPosted Feb 24, 2015, 9:22 PM EST
There are mainly 4 access modifier available in C#.
Public => which allow you to get accessed every where the code.
Private => which allow you to get accessed within its own class
protected=>which allow you to get accessed in its own class & immediate inherited class.
Internal => access limited to current assembly or library.
VulpesRank #55 · 29.2K reputationPosted Feb 25, 2015, 10:26 AM EST
This is the union of protected and internal access.
The CLR supports a sixth access modifier, known as 'famandassem', which is the intersection of protected and internal access but this isn't supported by either C# or VB.NET. However, it is supported in C++/CLI where it's called 'private protected'.
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 25, 2015, 6:30 PM EST
Hi,
Agree with Vulpes there are five access modifier.
Please refer
https://msdn.microsoft.com/en-us/library/ms173121.aspx
hope this will help you.
Rajeev KumarRank #1,334 · 1.3K reputationPosted Mar 16, 2023, 6:09 AM EDT
Access is limited to the containing class or types derived from the containing class within the current assembly.
Tuhin PaulRank #7 · 71.9K reputationPosted Mar 16, 2023, 10:38 AM EDT
There are five access modifiers in C#: