对于只有属性为连接字符串的类的所有rules for the GetHashCode method in MSDN,我遇到了困难。基于连接字符串实现GetHashCode
我已经尝试过只是返回字符串的散列,但是它为字符串Provider=Microsoft.ACE.OLEDB.12.0; Data Source=path
,Provider=Microsoft.ACE.OLEDB.12.0; Data Source=path;
和Data Source=path;Provider=Microsoft.ACE.OLEDB.12.0;
返回一个不同的值,所有这些都是等效的。
然后,我尝试使用OleDbConnectionStringBuilder.GetHashCode
方法,但是,这并不甚至返回相同的hashCode在这种情况下:
test1.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" +
PathToExcelFile + ";Extended Properties='Excel 12.0 Macro;HDR=YES;IMEX=1';";
test2.ConnectionString = test1.ConnectionString;
Console.WriteLine(test1.GetHashCode());
Console.WriteLine(test2.GetHashCode());
我的目标是用我的类作为主要的解释,所以GetHashCode的有点重要。我应该如何去实施它?
你必须写一个解析器。从正则表达式的框架中根本没有任何帮助。 – 2010-08-10 18:44:34