本文共 690 字,大约阅读时间需要 2 分钟。
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Collections;
- namespace TestArrayList
- {
- class Program
- {
- public struct SData
- {
- public int Index;
- public string Content;
- }
- static void Main(string[] args)
- {
- ArrayList aList = new ArrayList();
- SData d0 = new SData();
- d0.Index = 0;
- d0.Content = "d0";
- aList.Add(d0);
- SData d1 = new SData();
- d1.Index = 1;
- d1.Content = "d1";
- aList.Add(d1);
- SData d2 = new SData();
- d2.Index = 2;
- d2.Content = "d2";
- aList.Add(d2);
- foreach (SData d in aList)
- {
- Console.WriteLine("Index={0} Content={1}", d.Index, d.Content);
- }
- Console.WriteLine();
- Console.ReadLine();
- }
- }
- }
引用命令空间:
using System.Collections;
效果图:
参考文献:
转载地址:http://wjkmx.baihongyu.com/