Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8385769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:45:16+00:00 2026-06-09T17:45:16+00:00

I have a sorter which performs various comparisons. Resharper says I should change from

  • 0

I have a sorter which performs various comparisons. Resharper says I should change from String.CompareTo to String.CompareOrdinal. Does this really provide much benefit or is it something I should adjust the inspection rules for?

CompareTo:

config.Sort(delegate(configData data1, configData data2)
{
    if (data1.SettingName.Equals(data2.SettingName))
    {
        string m1 = data1.SettingMachine;
        string m2 = data2.SettingMachine;
        if (m1 == null)
            m1 = string.Empty;
        if (m2 == null)
            m2 = string.Empty;
        return m1.CompareTo(m2);
    }

    return data1.SettingName.CompareTo(data2.SettingName);
});

CompareOrdinal:

config.Sort(delegate(configData data1, configData data2)
{
    if (data1.SettingName.Equals(data2.SettingName))
    {
        string m1 = data1.SettingMachine;
        string m2 = data2.SettingMachine;
        if (m1 == null)
            m1 = string.Empty;
        if (m2 == null)
            m2 = string.Empty;
        return String.CompareOrdinal(m1, m2); ;
    }

    return String.CompareOrdinal(data1.SettingName, data2.SettingName);
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:45:17+00:00Added an answer on June 9, 2026 at 5:45 pm

    Resharper is concerned that if you were to run your code on a system which was using a different default character encoding, the comparison could fail. CompareOrdinal is culture-invariant, thus removing the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I implemented the table sorter yesterday and i have a problem trying to change
I have a PHP script which reads a large CSV and performs certain actions,
How would I go about this, I have files which I have sorted the
I have a list of an object which need to be sorted depending on
I have an array of values which is almost, but not quite sorted, with
Let's say I have a collection of objects which can be sorted using a
I need to have a navigation on which some links (those who are shorter
Ok, here's the deal. I have an array (inputted from a 400 MB file)
I have two Tablesorter tables in my website demo , which can be accessed
I have an excel sheet which has about 150,000 records, operations like find replace,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.