Ask Question

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

+2
Answers (1)
  1. 24 December, 10:50
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers