【发布时间】:2013-09-22 16:17:42
【问题描述】:
如何循环遍历列表并获取每个项目?
我希望输出如下所示:
Console.WriteLine("amount is {0}, and type is {1}", myMoney.amount, myMoney.type);
这是我的代码:
static void Main(string[] args)
{
List<Money> myMoney = new List<Money>
{
new Money{amount = 10, type = "US"},
new Money{amount = 20, type = "US"}
};
}
class Money
{
public int amount { get; set; }
public string type { get; set; }
}
【问题讨论】:
标签: c# for-loop collections