What is the C# equivalent of friend?

There’s no direct equivalent of “friend” – the closest that’s available (and it isn’t very close) is InternalsVisibleTo. I’ve only ever used this attribute for testing – where it’s very handy!

Example: To be placed in AssemblyInfo.cs

[assembly: InternalsVisibleTo("OtherAssembly")]

Leave a Comment