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 6774423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:47:06+00:00 2026-05-26T15:47:06+00:00

I was trying my hand over System.Gloablization in a small desktop app. I am

  • 0

I was trying my hand over System.Gloablization in a small desktop app. I am a bit confused about the additional control CultureInfo.Compare() has to offer than using String.Compare() method and its overloads.

Let’s say I have two strings

String s1 = "\u3057\u3093\u304B\u3093\u305b\u3093"; //some Japanese text in Unicode
String s2 = "\u30b7\u3043\u30ab\u30f3\u30bb\u30f3"; //Some Japanese text in Unicode
CultureInfo ci = new CultureInfo("ja-JP");

String.Compare has several overloads, out of which currently I would use

String.Compare(String strA, String strB, CultureInfo culture, CompareOptions options)

(where CompareOptions is an Enumerated type)

However, I could also use:

CompareInfo compareInfo = CompareInfo.GetCompareInfo("ja-JP");
compareInfo.Compare(String strA, String strB, CompareOptions options);

for the same purpose.

How does the CultureInfo’s CompareInfo object provide more control when handling such situation in globalization such as Japanese text for eg: CompareOptions.IgnoreKanaType (where Kana is a second form of Japanese which can be ignored from the string using CompareOptions enumaerated type).

  • 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-05-26T15:47:07+00:00Added an answer on May 26, 2026 at 3:47 pm

    Yes Jon skeet is right, String.Compare internally calls CultureInfo.Compare method, here is the actual code from IL:

        public static int Compare(string strA, string strB, CultureInfo culture, CompareOptions options)
    {
        if (culture == null)
        {
            throw new ArgumentNullException("culture");
        }
        return culture.CompareInfo.Compare(strA, strB, options);
    }
    

    The other thing to be noticed here is that, CultureInfo.Compare method internally does not check (at first) for input (culture) is null or not. It just directly does other operation. Also it does calls again string.Compare(string,string,StringOptions) API if OrdinalIgnoreCase is used.
    So best is to use String.Compare since there is a null checking before any operation is done.

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

Sidebar

Related Questions

After trying my hand at Perl and a little bit of C, I am
I am extremely frustrated with trying to prune and hand over to Protovis a
I'm trying my hand at behavior driven development and I'm finding myself second guessing
I'm trying my hand in the food industry. I'm going to be developing my
I've been curious in the past few months in trying my hand at doing
I'm trying to place this menu on the left hand side of the page:
I'm trying to run a particular JUnit test by hand on a Windows XP
I'm trying to make a function that will take short hand hex color to
I am trying to generate a RTF document by hand and eventually will do
I'm trying to write my own abstraction over the MessageBoxImage enumeration, and see that

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.