中級 › is inaccessible due to its protection level の原因と直し方 › パターン3
is inaccessible due to its protection level の原因と直し方
privateなメンバーにクラスの外部からアクセスしようとすると出るコンパイルエラーです。
1 class Config { 2 private string key = "secret-key"; 3 public string name = "app"; 4 } 5 class Program { 6 static void Main(string[] args) { 7 Config c = new Config(); 8 System.Console.WriteLine(c.____); ^ 9 } 10 }
Program.cs(8,36): error CS0122: 'Config.key' is inaccessible due to its protection level
空欄を埋めてビルドを通す
設定値の中でも機密性の高いものはprivateにして、外部から直接読めないようにします。
次の問題