且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#中的字符串比较忽略空格,回车或换行符

更新时间:2023-11-13 22:36:52

删除所有你不想要的字符,然后使用TOLOWER()方法来忽略大小写。

Remove all the characters you don't want and then use the ToLower() method to ignore case.

编辑:虽然上述作品,***使用 StringComparison.OrdinalIgnoreCase 。只是把它作为第二个参数等于方法。

edit: While the above works, it's better to use StringComparison.OrdinalIgnoreCase. Just pass it as the second argument to the Equals method.