'GetServiceCafe.EntityCafe.hasil.get' 访问器的可访问性必须比 属性 或索引器更受限制?
The accessibility of the 'GetServiceCafe.EntityCafe.hasil.get' accessor must be more restrictive than the property or indexer?
我的问题是当我尝试调试我的程序时出现错误 "The Property or indexer 'GetServiceCafe.EntityCafe.hasil' cannot be used in this context because the get accessor inaccessible"
我正在尝试用这个 accessor must be more restrictive than the property or indexer 修复它,但在我的情况下,主要问题是 get
未设置,我尝试将 get
更改为 public 但是仍然出现此错误。
EntityCafe.cs :
namespace GetServiceCafe
{
class EntityCafe
{
List<EntityData> hasil { get; set; }
}
public class EntityData
{
public int ID_Transaksi { get; set; }
public string Nama_Pemesan { get; set; }
public int Status { get; set; }
public string Detail_Pesanan { get; set; }
public int Total_Biaya { get; set; }
public string Jenis_Transaksi { get; set; }
public string Cabang { get; set; }
}
}
Form1.cs :
DataTable table = new DataTable("myTable");
table.Columns.Add("ID_Transaksi", typeof(string));
table.Columns.Add("Nama Pemesan", typeof(string));
table.Columns.Add("Detail Pesanan", typeof(string));
table.Columns.Add("Total_Biaya", typeof(string));
table.Columns.Add("Jenis_Transaksi", typeof(string));
table.Columns.Add("Cabang", typeof(string));
foreach (var obj in dataPengiriman.hasil)
{
DataRow row = table.NewRow();//empty row
row[0] = obj.id_transaksi.ToString();
row[1] = obj.nama_pemesan.ToString();
row[2] = obj.detail_pesanan.ToString();
row[3] = obj.total_biaya.ToString();
row[4] = obj.jenis_transaksi.ToString();
row[5] = obj.cabang.ToString();
table.Rows.Add(row);
}
无法访问该列表,因为它不是 public
,您可以获取 public
:
public class EntityCafe
{
public List<EntityData> hasil { get; private set; } // it should be Hasil
}
请注意,如果要从表单创建实例,class 也必须是 public
。
我的问题是当我尝试调试我的程序时出现错误 "The Property or indexer 'GetServiceCafe.EntityCafe.hasil' cannot be used in this context because the get accessor inaccessible"
我正在尝试用这个 accessor must be more restrictive than the property or indexer 修复它,但在我的情况下,主要问题是 get
未设置,我尝试将 get
更改为 public 但是仍然出现此错误。
EntityCafe.cs :
namespace GetServiceCafe
{
class EntityCafe
{
List<EntityData> hasil { get; set; }
}
public class EntityData
{
public int ID_Transaksi { get; set; }
public string Nama_Pemesan { get; set; }
public int Status { get; set; }
public string Detail_Pesanan { get; set; }
public int Total_Biaya { get; set; }
public string Jenis_Transaksi { get; set; }
public string Cabang { get; set; }
}
}
Form1.cs :
DataTable table = new DataTable("myTable");
table.Columns.Add("ID_Transaksi", typeof(string));
table.Columns.Add("Nama Pemesan", typeof(string));
table.Columns.Add("Detail Pesanan", typeof(string));
table.Columns.Add("Total_Biaya", typeof(string));
table.Columns.Add("Jenis_Transaksi", typeof(string));
table.Columns.Add("Cabang", typeof(string));
foreach (var obj in dataPengiriman.hasil)
{
DataRow row = table.NewRow();//empty row
row[0] = obj.id_transaksi.ToString();
row[1] = obj.nama_pemesan.ToString();
row[2] = obj.detail_pesanan.ToString();
row[3] = obj.total_biaya.ToString();
row[4] = obj.jenis_transaksi.ToString();
row[5] = obj.cabang.ToString();
table.Rows.Add(row);
}
无法访问该列表,因为它不是 public
,您可以获取 public
:
public class EntityCafe
{
public List<EntityData> hasil { get; private set; } // it should be Hasil
}
请注意,如果要从表单创建实例,class 也必须是 public
。