Domanda

I have a class A_class in Project A. In class A_class, there is a constructor

internal A_class()
 {
  //constructor logic
 }

, and a member variable internal int A_member;

Now there are two friend assemblies, say Assembly B and Assembly C I want Assembly B to be able to access only and only A_Class() I want Assembly C to be able to access only and only A_member Such that, Assembly B can not access A_member, and Assembly C can not access A_class()

Is it possible ? Or is there any other alternative for this ?

If i use

[assembly: InternalsVisibleTo("B")]
[assembly: InternalsVisibleTo("C")]

Then both B and C will have access to both A_class() and A_Member, which is not desired

È stato utile?

Soluzione

The attribute InternalsVisibleTo is applied only at the assembly level

The attribute is applied at the assembly level.

http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx

You cannot provide differentiated access to the class and member as you desire.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top