internal C# with Example



internal C# with Example

The internal keyword makes a class (including nested classes), property, method or field available to every 
consumer in the same assembly: 
internal class Foo 
{ 
internal string SomeProperty {get; set;} 
} 
internal class Bar 
{ 
var myInstance = new Foo(); 
internal string SomeField = foo.SomeProperty; 
internal class Baz 
{ 
private string blah; 
public int N { get; set; } 
} 
 

} 
This can be broken to allow a testing assembly to access the code via adding code to AssemblyInfo.cs file: 
using System.Runtime.CompilerServices; 
[assembly:InternalsVisibleTo("MyTests")] 

0 Comment's

Comment Form

Submit Comment