首页 > Windows开发 > 详细

C# - InnerList

时间:2015-05-19 22:22:14      阅读:330      评论:0      收藏:0      [点我收藏+]

运行效果:

技术分享

 

 

 

代码:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace InnerList
 7 {
 8     class Program
 9     {
10         static void Main(string[] args)
11         {
12             strList sl = new strList();
13 
14             sl.Add("A");
15             sl.Add("B");
16             sl.Add("C");
17 
18             Console.WriteLine(sl[1]);
19             sl.Remove("A");
20             Console.WriteLine(sl[1]);
21 
22             Console.ReadKey();
23         }
24     }
25 
26     /// <summary>
27     /// 用System.Collections.CollectionBase定义一个存储字符类型的列表类
28     /// </summary>
29     public class strList : System.Collections.CollectionBase
30     {
31         /// <summary>
32         /// 像列表中添加字符串
33         /// </summary>
34         /// <param name="str"></param>
35         public void Add(string str)
36         {
37             base.InnerList.Add(str);
38         }
39 
40         /// <summary>
41         /// 从列表中一处移除字符串
42         /// </summary>
43         /// <param name="str"></param>
44         public void Remove(string str)
45         {
46             base.InnerList.Remove(str);
47         }
48 
49         /// <summary>
50         /// 根据索引号,查找指定字符串
51         /// </summary>
52         /// <param name="Index"></param>
53         /// <returns></returns>
54         public string this[int Index]
55         {
56             get { return ((string)List[Index]); }
57             set { List[Index] = value; }
58         }
59     }
60 }

 

C# - InnerList

原文:http://www.cnblogs.com/KTblog/p/4515647.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!