F# 不区分大小写的字符串比较

标签 f#

在 F# 中是否有一种语法更清晰的方法来执行不区分大小写的字符串比较,而不是以下方法

System.String.Equals("test", "TeSt", System.StringComparison.CurrentCultureIgnoreCase)

最佳答案

此外,您可以使用 F# type extensions力学:

> type System.String with
-   member s1.icompare(s2: string) =
-     System.String.Equals(s1, s2, System.StringComparison.CurrentCultureIgnoreCase);;
> "test".icompare "tEst";;
val it : bool = true

关于F# 不区分大小写的字符串比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1936767/

相关文章:

f# - Xamarin Android : F# icon not being picked up by Resources

generics - F#:IEnumerable<Tuple<TA,TB>> 与 list<TA*TB> 不兼容?

http - JsonProvider 如何与需要身份验证的 URL 一起使用?

f# - 如何实现不定式数据结构以在 F# 中按需获取项目

f# - F# 的 async 究竟是如何工作的?

f# - 函数返回类型unit而不是类型ref

F# 在 do block 中包装语句

winforms - 在 F# 中绘制 Windows 窗体

f# - 通用函数签名

f#: program to calculate difference between dates