I have a class A with a public method in C#. I want to allow access to this method to only class B. Is this possible?
UPDATE:
This is what i
You can if you make class A
a private, nested class inside class B
:
class B
{
class A
{
public Int32 Foo { get; set; }
}
}
Only B
will be able to see A
and it's members in this example.
Alternatively you could nest B
inside A
:
class A
{
Int32 Foo { get; set; }
public class B { }
}
In this case everyone can see both A
and B
but only B
can see A.Foo
.