http://topic.csdn.net/u/20081031/15/0f31a340-d473-4c88-b859-256eea7e9132.html
其实很简单
Dictionary <string, object> dictionary = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase);
当初也是不知道有这个构造函数绕了个大圈子。MS的设计确实有点水准的。
--------------------------------------------------
http://topic.csdn.net/t/20050427/16/3971146.html
再写一遍:
new Hashtable(System.StringComparer.Create(System.Globalization.CultureInfo.CurrentCulture, true))
vwxyzh:
我是要实现一个自己的hashtable类提供给我的用户去调用API,不是让用户写你提供的方法去new一个出来,请问我自己的类怎么达到你写的这种功能
我这样写可是编译不过:
public class MyHash:Hashtable
{
public MyHash() {
base(System.StringComparer.Create(System.Globalization.CultureInfo.CurrentCulture, true));
}
}
说是在此上下文中使用base无效,看来与java不一样啊
c#里面是这么写的:
public MyHash()
: base(System.StringComparer.Create(System.Globalization.CultureInfo.CurrentCulture, true))
{
}
--------------------------------------------------
针对数组可以用List.Distinct(),可以过滤掉重复的内容。
针对对象中的某个字段只能用Distinct(IEqualityComparer<T>)
用法:
针对数组可以用List.Distinct(),可以过滤掉重复的内容。
针对对象中的某个字段只能用Distinct(IEqualityComparer<T>)
用法: