所以我用get / set类来处理我的列表,如下所示
class Account
{
public List<int> ID { get; set; }
public List<string> Name { get; set; }
public List<decimal> Money { get; set; }
public List<string> BorP { get; set; }
}
class Tran
{
public List<int> ID { get; set; }
public List<decimal> Amount { get; set; }
}
但是我遇到麻烦的是像这样并排显示所有信息
Id Name Money BorP
我厌倦了嵌套for循环而无法让它工作,因为你可以看到即时通讯使用列表。输出这样的东西的最佳方法是什么?
以下是我宣布的方式
Account items = new Account();
items.ID = importedNumbers;
items.Name = people;
items.Money = Money;
items.BorP = BorP;
这在控制台应用程序中。
答案 0 :(得分:0)
这个怎么样?
class Account
{
public int ID { get; set; }
public string Name { get; set; }
public decimal Money { get; set; }
public string BorP { get; set; }
}
class Tran
{
public int ID { get; set; }
public decimal Amount { get; set; }
}
class TableAccount
{
public List<Account> Rows {get; set;}
}
class TableTrans
{
public List<Tran> Rows {get; set;}
}
答案 1 :(得分:0)
如果您有相关数据,那么数据本身不应该在列表中,它应该在单个引用中。如果您有一系列这些关联对象,请考虑使用List<Account>
使用Account
。
class Account
{
public int ID { get; set; }
public string Name { get; set; }
public decimal Money { get; set; }
public string BorP { get; set; }
public List<Transaction> Transactions { get; set; }
}
class Tran
{
public int ID { get; set; }
public decimal Amount { get; set; }
}
唯一的其他选择是使用索引,因为列表保证订购