Concept of Private class in C#

后端 未结 5 1550
忘掉有多难
忘掉有多难 2021-02-01 01:48

Can private classes exist in C#, other than in Inner classes?

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 02:09

    In what scenario other then for an innter class would you like to have a 'private' class ?

    You can use the internal modifier to create a class that is only visible in the current assembly.

    // the class below is only visible inside the assembly in where it was declared
    internal class MyClass
    {
    }
    

提交回复
热议问题