Good day!

Here I found out that in C # there are two very similar enumerated types: StringComparer и StringComparison . I wonder if they have any significant differences and areas of application? Are they aliases like string И String , for example? For example:

 a) StringComparer a = StringComparer.OrdinalIgnoreCase; b) StringComparison b = StringComparison.OrdinalIgnoreCase; 

Is there any difference?

  • (I'm not sure that I state everything correctly, therefore a comment, not an answer.) So. These are not aliases, but there are no significant differences, besides where they can be transferred. Different types that do not replace one another (there will be an error of type conversion), but there seems to be no pitfalls in their difference. - Maxim Kamalov 7:09
  • Aaaaa, there are no pitfalls, if one is an abstract class , and the second is enum ? o0 - eigenein
  • This is what I meant by non-substitution. Stone, of course, but not underwater :) - Maxim Kamalov

1 answer 1

StringComparer is not an enumerable type, it is an abstract class, and its OrdinalIgnoreCase field is an object of the StringComparer class. StringComparison is really enum .

Actually, the difference between them is fundamental: StringComparer.OrdinalIgnoreCase is an object that can compare strings, StringComparison.OrdinalIgnoreCase is actually int .

  • Hmm, well, yes, exactly, an abstract class. For some reason, he did not notice the methods inherited from object ... well, on the basis of this, much is becoming explicable. Thank! - Salivan