What is the equivalent of a 'friend' keyword in C Sharp?

前端 未结 7 1164
既然无缘
既然无缘 2021-02-18 15:52

What is the equivalent of a \'friend\' keyword in C Sharp?

How do I use the \'internal\' keyword?

I have read that \'internal\' keyword is a replacement for \'fr

7条回答
  •  后悔当初
    2021-02-18 16:28

    1. internal is the C# equivalent of the VB.NET friend keyword, as you have guessed (as opposed to a replacement)

    2. Usage is as follows

      internal void Function() {}
      internal Class Classname() {}
      internal int myInt;
      internal int MyProperty { get; set; }
      
    3. It, basically, is an access modifier that stipulates that the accessibility of the class / function / variable / property marked as internal is as if it were public to the Assembly it is compiled in, and private to any other assemblies

提交回复
热议问题