13、C 数据存储:集合与 XML 的应用

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(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值