I need some clarification as to what exactly you mean by "specific classes"... but I'm hoping that I'm interpreting correctly in that you only want instances of class A to be able to call the method.
public class A
{
private int number;
private void setNumber(int Number)
{
number = Number;
}
}
In this case, any instances of class A can call the method:
A myAinstance = new A();
myAinstance.setNumber(5);
However, you wouldn't be able to refer to A.setNumber() as if it were a static method - without relation to an instance.
If you want only derived classes (from any assembly) to be able to call it:
public class A
{
private int number;
protected void setNumber(int Number)
{
number = Number;
}
}
public class B : A
{
}
In this case, any instances of class B or A could call setNumber(), but no other classes could see or access it.
If you only want all instances classes within the same assembly to be able to call it:
public class A
{
private int number;
internal void setNumber(int Number)
{
number = Number;
}
}
In this case, any classes within the same assembly as your class 'A' will be able to call setNumber() as if it were a public property, but no classes contained in other assemblies will be able to see it or reference it. In VB.NET internal is the same as 'Friend'.
If you only want derived classes within the same assembly to be able to call it:
public class A
{
private int number;
protected internal void setNumber(int Number)
{
number = Number;
}
}
public class B : A
{
}
In this case, any instances of class B or A regardless of assembly can see and reference setNumber(); and any classes within the same assembly as class A will be able to see it or reference it as if it were public.
I think that covers each of the options...