[.net] [C#] internal, assembly and C++ friends

Started by
7 comments, last by SnOrfys 16 years, 8 months ago
I'm looking for the C# equivalent of a C++ friend class modifier. Apparently you can use the 'internal' keyword to implement unrestricted access within the same assembly, but what exactly is defined as an assembly? Does the code/classes have to be in the same file? Is the executable defined as a single assembly?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Advertisement
That's right. Assembly is a .dll or .exe file.
Quote:Original post by Rattenhirn
That's right. Assembly is a .dll or .exe file.

So then there is nothing that will allow a single class unrestricted access to another's members? Assuming that the classes are completely seperate and not related (inherited, etc) in any way.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
That's right as well.
The friend concept doesn't exist in C# at all.
Drat.

Now, is that a good thing or a bad thing? Because I've occasionally found it useful for certain design decisions in C++.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
friend classes are a bad oop practice.
Quote:Original post by SnOrfys
friend classes are a bad oop practice.

It depends on who you ask.
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
In C#, the only way I know of to give one class access to the other's private data is to make it a nested class.
Quote:Original post by dalleboy
Quote:Original post by SnOrfys
friend classes are a bad oop practice.

It depends on who you ask.


Very true.

This topic is closed to new replies.

Advertisement