internal cho phép internal access specifier. Thành viên internal truy cập được từ bất kỳ lớp/phương thức nào trong cùng assembly.
Ví dụ
using System;
namespace RectangleApplication {
class Rectangle {
internal double length;
internal double width;
double GetArea() { return length * width; }
public void Display() {
Console.WriteLine("Length: {0}", length);
Console.WriteLine("Width: {0}", width);
Console.WriteLine("Area: {0}", GetArea());
}
}
class Demo {
static void Main(string[] args) {
Rectangle rc = new Rectangle();
rc.length = 10.35; rc.width = 8.3;
rc.Display();
Console.ReadLine();
}
}
}