我是靠谱客的博主 大胆树叶,这篇文章主要介绍SPRING.NET 1.3.2 学习12--为索引器属性赋值,现在分享给大家,希望可以做个参考。

假设有如下类,有两个索引器,一个是整形,一个是字符串

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class Person { private IList favoriteNames = new ArrayList(); private IDictionary properties = new Hashtable(); public Person() { favoriteNames.Add("p1"); favoriteNames.Add("p2"); } public string this[int index] { get { return (string) favoriteNames[index]; } set { favoriteNames[index] = value; } } public string this[string keyName] { get { return (string) properties[keyName]; } set { properties.Add(keyName, value); } } }

下面的对象定义为索引器赋值

复制代码
1
2
3
4
<object id="person" type="Test.Objects.Person, Test.Objects"> <property name="[0]" value="Master Shake"/> <property name="['one']" value="uno"/> </object>

老的1.02版本写法不同,这里不再研究,直接跳过

最后

以上就是大胆树叶最近收集整理的关于SPRING.NET 1.3.2 学习12--为索引器属性赋值的全部内容,更多相关SPRING.NET内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部