I want to compare two strings and one of them may be a null string, am using StringComparison.InvariantCultureIgnoreCase feature of C#. This throws an exception in runtime when a null string is encountered. What shall I do to be able to compare even null strings?
I want to compare two strings and one of them may be a null
Share
As well as the options already given to you, you can consider using
StringComparer.InvariantCultureIgnoreCaseinstead.StringComparerhandles nulls without throwing exceptions: