- In comparing two values, the .NET Framework differentiates the concepts of equality comparison and order comparison.
- Equality comparison tests whether two instances are semantically the same.
- Order comparison tests which of two (if any) instances comes first when arranging them in ascending or descending sequence.
- For string Equality comparison, you can use the
- == Operator
- string.Equals() static method as will as instance method, this option is better because they allow you to specify options such as case-sentitvity/culture-sensitivity.
- For string Order comparison, you can use the
- CompareTo() instance method
- string.Compare() static method
- stirng.CompareOrdinal() static method
- The return values of above said methods will be
- 0 for equal
- 1 if first value comes before second value
- 2 if second value comes before first value
Framework Fundamentals - String - Comparing Strings
Subscribe to:
Post Comments (Atom)
Framework Fundamentals - String - Comparing Strings
In comparing two values, the .NET Framework differentiates the concepts of equality comparison and order comparison . Equality compariso...
-
The grouping operators assist with grouping elements of a sequence together by a common key. GroupBy operator return a sequence of IGrouping...
-
ToArray and ToList The ToArray operator creates an array of type T from an input sequence of type T. List<string> StudentNames = new L...
-
The partitioning operators allow you to return an output sequence that is a subset of an input sequence. Take - Example -1 class Course ...
No comments:
Post a Comment