是否有一种语法上更清晰的方法来在F#中执行不区分大小写的字符串比较,而不是以下方法
System.String.Equals("test", "TeSt", System.StringComparison.CurrentCultureIgnoreCase)
Run Code Online (Sandbox Code Playgroud)
此外,您可以使用F#类型扩展机制:
> type System.String with
- member s1.icompare(s2: string) =
- System.String.Equals(s1, s2, System.StringComparison.CurrentCultureIgnoreCase);;
> "test".icompare "tEst";;
val it : bool = true
Run Code Online (Sandbox Code Playgroud)
编写一个扩展方法来使其更短怎么样?
| 归档时间: |
|
| 查看次数: |
6117 次 |
| 最近记录: |