を引き起こし、私は次のようにVS2005を使用してC#でクラスを作成しようとしています:C#のIListパラメータは一貫性のないアクセス
public class MyClass
{
private string reference;
private IList<MyClassItem> items;
public MyClass(string reference, IList<MyClassItem> items) // error here
{
this.reference = reference ;
this.items = items;
}
public string Reference { get { return this.reference ; } set { this.reference = value; } }
public IList<MyClassItem> Items { get { return this.items; } set { this.items = value; } } // error line
}
public class MyClassItem
{
private string id;
private string name;
public MyClassItem(string id, string name)
{
this.id= id;
this.name= name;
}
public string Id{ get { return this.id; } set { this.id= value; } }
public string Name { get { return this.name; } set { this.name= value;}}
}
私はエラーだ:
Inconsistent accessibility: parameter type '
System.Collections.Generic.IList<Library.Model.MyClassItem>
' is less accessible than method 'Library.Model.MyClass.Jurnal(string, System.Collections.Generic.IList<Library.Model.MyClassItem>)
' D:...\MyClass.cs 15 16 Library Error 4 Inconsistent accessibility: property type 'System.Collections.Generic.IList<Library.Model.MyClassItem>
' is less accessible than property 'Library.Model.MyClass.Items' D:...\MyClass.cs 28 34 Library
「MyClassItem」はあなたがそれを公開したように公開されていますか?問題を示す[mcve]を提供できますか?これらのクラスはネストされていますか? –
投稿されたコードはエラーを起こさない。コピー/貼り付け中やコード短縮時にエラーが発生しました。 –
@ JonSkeet私のコードでMyClassItemの 'public'を忘れてしまった...皆さんありがとう – Jackie