Ask Question
26 December, 05:44

What are the field/method access levels (specifiers) and class access levels?

+1
Answers (1)
  1. 26 December, 08:20
    0
    There are 5 access specifiers totally in C#

    Explanation:

    In C# there are 5 different access specifiers.

    1. Private

    2. Protected

    3. Internal

    4. Protected Internal

    5. Public

    Fields or methods can have all the access modifiers, where as classes can have only 2 (internal, public) of the 5 access specifiers.

    I have explained the usage of each access modifier below.

    Private:

    Private members are available only with in the containing type.

    Public:

    Public members are available any where. There is no restriction.

    Internal: Internal members are available anywhere in the containing assembly.

    Protected:

    Protected Members are available, with in the containing type and to the types that derive from the containing type.

    Protected Internal:

    These are available anywhere within containing assembly and from within a derived class in any another assembly.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What are the field/method access levels (specifiers) and class access levels? ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers