C#内部VS VBNET朋友 [英] C# internal VS VBNET Friend
问题描述
对于这个SO问题:朋友的C#等效项是什么?,我个人会回答内部",就像Jas在回答中一样!但是,乔恩·斯凯特(Jon Skeet)说,C#中没有VB Friend的直接等效项.如果乔恩·斯凯特(Jon Skeet)这么说,我不会是那个告诉别人的人! ; P
To this SO question: What is the C# equivalent of friend?, I would personally have answered "internal", just like Ja did among the answers! However, Jon Skeet says that there is no direct equivalence of VB Friend in C#. If Jon Skeet says so, I won't be the one telling otherwise! ;P
我想知道关键字内部(C# )当它们各自的定义时,不等同于朋友(VBNET)是:
I'm wondering how can the keyword internal (C#) not be the equivalent of Friend (VBNET) when their respective definitions are:
朋友VBNET >
声明语句中的朋友(Visual Basic)关键字指定可以从同一装配件内部访问元素,但不能从装配件外部访问元素. [...]
The Friend (Visual Basic) keyword in the declaration statement specifies that the elements can be accessed from within the same assembly, but not from outside the assembly. [...]
内部C# >
内部:访问仅限于当前程序集. /p>
Internal: Access is limited to the current assembly.
据我所知,这些定义对我来说含义完全相同.
To my understanding, these definitions mean quite the same to me.
然后分别在VB.NET中进行编码时,使用 Friend 关键字指定仅在声明了该类或属性的程序集中才能访问该类或属性.在C#中相同,我使用 internal 关键字指定相同的内容.
Then, respectively, when I'm coding in VB.NET, I use the Friend keyword to specify that a class or a property shall be accessible only within the assembly where it is declared. The same in C#, I use the internal keyword to specify the same.
-
从这个角度看我是在做错什么事吗?
Am I doing something or anything wrong from this perspective?
我没有得到哪些改进?
请问某人请说明与朋友和内部人不是直接对等的方式或方式吗?
Might someone please explain how or in what Friend and internal are not direct equivalences?
在此先感谢您的回答!
推荐答案
我说过,没有直接等价于 C ++ 朋友"概念的人.这与VB.NET Friend
概念不同,实际上等同于C#中的internal
.
I've said there's no direct equivalent of the C++ "friend" concept. That's not the same as the VB.NET Friend
concept, which is indeed equivalent to internal
in C#.
上下文很重要-不要假设相同的词在所有语言中都具有完全相同的含义……静态"是一个典型的例子:)
Context is important - don't assume that the same word means exactly the same thing in all languages... "static" is a classic example :)
这篇关于C#内部VS VBNET朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!