The attribute is applied at the assembly level.
This means that it can be included at the beginning of a source code file,
or it can be included in the AssemblyInfo file in a Visual Studio project.
You can use the attribute to specify a single friend assembly that can access
the internal types and members of the current assembly.
您可以在源代码文件的开头添加该属性。您不能用它标记单个方法,请参阅MSDN - 文档。
如果要拆分类的可见和不可见方法,可以执行以下操作:
在一个文件中,定义您的可见方法并将文件标记为可见:
InternalsVisibleTo("NameOfOtherAssembly")]
public partial class Foo
{
internal void Visible(){}
}
在另一个文件中,定义您的不可见方法:
public partial class Foo
{
internal void IsNotVisible(){}
}