StringComparer.InvariantCultureIgnoreCase Equals为""vs"\ 0"返回true,但GetHashCode为这两个字符串返回不同的值.这是一个错误吗?
var sc = StringComparer.InvariantCultureIgnoreCase;
string s1 = "";
string s2 = "\0";
Console.WriteLine( sc.Equals(s1, s2) );
Console.WriteLine( sc.GetHashCode(s1) );
Console.WriteLine( sc.GetHashCode(s2) );
Run Code Online (Sandbox Code Playgroud)
回报
True
0
-1644535362
Run Code Online (Sandbox Code Playgroud)
我认为GetHashCode应该为'equal'字符串返回相同的值,所以这是一个错误吗?
FSharp.Data.JsonProvider提供了从json到F#类型的方法.是否可以反向进行,即声明FSharp.Data.JsonProvider创建的其中一种类型的实例,将字段值设置为我需要的值,然后得到等效的json?
我尝试过这样的事情,
type Simple = JsonProvider<""" { "name":"John", "age":94 } """>
let fred = Simple(
Age = 5, // no argument or settable property 'Age'
Name = "Fred")
Run Code Online (Sandbox Code Playgroud)