中級 › does not implement interface member の原因と直し方 › パターン3
does not implement interface member の原因と直し方
インターフェースを実装すると宣言したクラスが、そのメンバーの一部を実装していないときに出るコンパイルエラーです。
1 interface IDescribable { 2 string Describe(); 3 } 4 class Book : IDescribable { 5 public string Title; 6 ___________________________________________ ^ 7 } 8 class Program { 9 static void Main(string[] args) { 10 Book b = new Book { Title = "C#" }; 11 System.Console.WriteLine(b.Describe()); 12 } 13 }
Program.cs(4,14): error CS0535: 'Book' does not implement interface member 'IDescribable.Describe()'
空欄を埋めてビルドを通す
publicを付け忘れるとアクセスレベルの不一致で同じCS0535になります。
次の問題