C# 数据存储:集合与 XML 的应用
集合存储数据的应用
在 C# 编程中,集合是一种强大的数据存储方式。以存储地址信息为例,我们可以使用 List 集合来管理多个地址。
首先,我们需要创建一个公共变量来存储 Addresses 结构的多个实例。代码如下:
// Declare a List of addresses.
List<Addresses> MyAddresses;
// Keep track of the current entry.
Int32 CurrentEntry;
public Form1()
{
InitializeComponent();
// Initialize the array.
MyAddresses = new List<Addresses>();
// Add entries to the array.
MyAddresses.Add(
new Addresses(
"Mark Hanson", "123 Anywhere Street", "Somewhere", "UT", "99999"));
MyAddresses.Add(
new Addresses(
"Kim Abercrombie", "456 5th Avenue", "Outback", "AK", "99998"));
MyAddresses.Add(
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



