首页 > 其他 > 详细

索引器基类定义

时间:2019-10-17 21:32:00      阅读:78      评论:0      收藏:0      [点我收藏+]
 1   public  class ClassIndex
 2     {
 3        
 4         public object this[string index]
 5         {
 6             get
 7             {
 8                 object result = null;
 9                 foreach (var item in this.GetType().GetProperties())
10                 {
11                     if (index == item.Name)
12                     {
13                         result = item.GetValue(item);
14                     }
15 
16                 }
17                 return result;
18             }
19             set
20             {
21                 foreach (var item in this.GetType().GetProperties())
22                 {
23                     if (index == item.Name)
24                     {
25                         item.SetValue(this, value,null);
26                         
27                     }
28                 }
29 
30             }
31 
32         }
33     }

 

索引器基类定义

原文:https://www.cnblogs.com/ugvihc/p/11695010.html

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