标签:
1、简单的函数,实现Dictionary如果有就替换,没有就增加的功能。
/// <summary>
/// Dictionary增加的方法
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dict"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public static Dictionary<TKey, TValue> AddOrReplace<TKey, TValue>(this Dictionary<TKey, TValue> dict, TKey key, TValue value)
{
dict[key] = value;
return dict;
}
标签:
原文地址:http://www.cnblogs.com/hanjiaxu/p/4736290.html