开发者

Why there are no friend classes in C#? [duplicate]

开发者 https://www.devze.com 2022-12-14 00:02 出处:网络
This question already has answers here: Closed 13 years ago. 开发者_JS百科 Possible Duplicate: Why does C# not provide the C++ style ‘friend’ keyword?
This question already has answers here: Closed 13 years ago. 开发者_JS百科

Possible Duplicate:

Why does C# not provide the C++ style ‘friend’ keyword?

A typical example where it might be needed

I have a class with private Init() function and class factory which I would like to grant access to Init();


There are no friends in C#, it's true, but you can put these classes into same file, so they both will be able to access each other's functions. Or use "partial" classes, putting only init() function of each class into the same file where your factory resides

0

精彩评论

暂无评论...
验证码 换一张
取 消