Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12401324
  • 博文数量: 1293
  • 博客积分: 13501
  • 博客等级: 上将
  • 技术积分: 17974
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 18:11
文章分类

全部博文(1293)

文章存档

2019年(1)

2018年(1)

2016年(118)

2015年(257)

2014年(128)

2013年(222)

2012年(229)

2011年(337)

分类: C#/.net

2013-11-21 15:30:39

    有时候需要使用一个数据字典的表来罗列大批的数据,这时使用List是比较好的方法。

  1. class Program
  2. {
  3.     public static List<string> STAR_LIST = new List<string>() { "Kobe","James","Wade","Durant"};
  4.     static void Main(string[] args)
  5.     {
  6.         int index1 = STAR_LIST.IndexOf("Kobe");
  7.         int index2 = STAR_LIST.IndexOf("James");
  8.         int index3 = STAR_LIST.IndexOf("Wade");
  9.         Console.WriteLine("{0},{1},{2}", index1, index2, index3);
  10.         Console.ReadLine();
  11.     }
  12. }


    上面的球星表清晰的列出了有那些球星。在实际开发过程中,这个表被用于的机率很高。main()中的使用是就是典型的应用之一,用来取得相应的索引。

 

image

阅读(4349) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~