Я пытаюсь создать класс в C# с помощью VS2005 следующим образом:параметр 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 в моем коде ... спасибо, ребята, у вас отличный день – Jackie