Equivalent of the C++ "friend" class modifier
-
Is there such a thing in C#? I know of the internal class modifier, but I want to grant "friend"-like access to a particular class from a different assembly. The reasons why I need this are long an involved, and the company I work for won't budge on the issue, so I need to find a way to make this work. Any ideas? Thanks.
-
Is there such a thing in C#? I know of the internal class modifier, but I want to grant "friend"-like access to a particular class from a different assembly. The reasons why I need this are long an involved, and the company I work for won't budge on the issue, so I need to find a way to make this work. Any ideas? Thanks.
Not possible with top-level types in C#. There is no real eqivalent to c++ friend access level. Your only alternative would be to derive the class that needs access from a puplic top level class that contains the class you want to access as a protected or protected internal class, which is a kludge that sort of defeats the pupose of not making the class you need access to public in the first place. What is your employer REALLY trying to accomplish here? Do you need access to the entire class, or just a few methods? Do you need to instantiate the class in the other assembly? Would a public wrapper class containing an instance the 'protected' class and exposing only the desired methods suffice (i.e. a facade)?- expose the facade class via a public class factory... Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed. Carl Sandburg
-
Is there such a thing in C#? I know of the internal class modifier, but I want to grant "friend"-like access to a particular class from a different assembly. The reasons why I need this are long an involved, and the company I work for won't budge on the issue, so I need to find a way to make this work. Any ideas? Thanks.
-
I'm not sure what the attribute is right now, but there is a way to make objects callable only from specified assemblies. If ur calling object is managed and u can place it in an isolated assembly then u can reach the solution u are looking for.