Does C# have the equivalent of Delphi's private modifier
In Delphi, the private modifier is likely unique:
Contoso = class
private
procedure DoStuff();
end;
you would think has the C# equivalent of:
class Contoso
{
private void DoStuff()
{
}
}
But in Delphi, the private keyword is more unit friend. In other words,
other classes in the same code file can access private members.
Transcoding Delphi to C#, it would be the equivalent of the following code
working:
public class Contoso
{
private void DoStuff()
{
}
}
internal class Fabrikam
{
Contoso _contoso;
//constructor
Fabrikam()
{
_contoso = new Contoso();
_contoso.DoStuff(); //i can call a private method of another class
}
}
Even though the method DoStuff is private to Contoso, other classes in the
same file can call the method.
What i don't want is to make the method internal:
class Contoso
{
internal void DoStuff();
}
because then other code in the assembly can see or call the DoStuff
method; which i don't want.
Does C# support some sort of unit friend or unit internal access modifier?
No comments:
Post a Comment