0
我的問題是,當我嘗試調試我的程序,我得到錯誤「屬性或索引‘GetServiceCafe.EntityCafe.hasil’不能在這種情況下,因爲get訪問無法訪問使用」'GetServiceCafe.EntityCafe.hasil.get'訪問器的可訪問性必須比屬性或索引器更具限制性嗎?
我試圖與修復它這accessor must be more restrictive than the property or indexer但在我的情況下,主要問題是get
未設置,我試圖將get
更改爲公共,但仍然得到此錯誤。
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);
}
明白了,非常感謝。 – liantokate