首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

asp.net c#非常简单的有关问题,解决马下给分

2013-03-13 
asp.net c#非常简单的问题,解决马上给分Dictionarystring, string是键和值的集合,那有没有非集合的写法?

asp.net c#非常简单的问题,解决马上给分
Dictionary<string, string>是键和值的集合,那有没有非集合的写法?
我不需要集合,但需要像Dictionary一样能够设置key和value

例如:


public object<string, string> demo(){
    return null;
}

以上代码是错误的,没有这种写法
[解决办法]
KeyValuePair<int, string> pair = new KeyValuePair<int, string>();
[解决办法]
自己定义一个
 public class myObject<TKey, TValue>
    {
        public TKey Key { get; set; }
        public TValue Value { get; set; }
    }

public myObject<string, string> demo(){
    return null;
}

热点排行