Where has StringComparison.InvariantCultureIgnoreCase gone?

后端 未结 2 727
Happy的楠姐
Happy的楠姐 2021-02-18 17:17

I\'m porting C# code to a Windows Store App. To my surprise the following code does not work anymore:

someString.Equals(\"someOtherString\", StringComparison.Inv         


        
2条回答
  •  我寻月下人不归
    2021-02-18 18:02

    Those specific options have not gone anywhere, but they are just not supported by Windows Store Apps.

    If you look at MSDN for StringComparison Enumeration you'll see those specific options are not supported by the Portable library or .NET for Windows Store.

    The only options that are supported for the Portable Library or Windows Store Apps are:

    • CurrentCulture
    • CurrentCultureIgnoreCase
    • Ordinal
    • OrdinalIgnoreCase

    I can't speak for why, but there is not an option to "replace" as those values do not exist within the framework. You'll have to work with one of the other options that do exist, StringComparison.OrdinalIgnoreCase is probably going to be the easiest to work with.

提交回复
热议问题