asp.net c#非常简单的有关问题,解决马下给分
asp.net c#非常简单的问题,解决马上给分
Dictionary<string, string>是键和值的集合,那有没有非集合的写法?
我不需要集合,但需要像Dictionary一样能够设置key和value
例如:
以上代码是错误的,没有这种写法
------解决方案--------------------
KeyValuePair<int, string> pair = new KeyValuePair<int, string>();
------解决方案--------------------
自己定义一个
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;
}