protected internal อนุญาตให้ซ่อนสมาชิกจากคลาสและฟังก์ชันอื่น ยกเว้นคลาสลูกภายในแอปพลิเคชันเดียวกัน
ในตัวอย่าง คลาสสืบทอดเข้าถึงตัวแปร protected internal ได้:
ตัวอย่าง
using System;
class One { protected internal int a = 50; private int b; }
class Two : One {
public Two() { Console.WriteLine(this.a); }
}
class Demo {
static void Main() {
Two t = new Two();
// อนุญาตเพราะเป็นอ็อบเจกต์คลาสลูก
t.a = 20;
}
}
ผลลัพธ์
50