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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:58:34+00:00 2026-05-29T22:58:34+00:00

In a lot of places I’m using the == operator to compare the string,

  • 0

In a lot of places I’m using the == operator to compare the string, now I know this considers casing… Is there anyway I can adjust the culture settings to avoid this or do I have to go to every line of code and change it to

string.Compare(a,b,StringComparison.CurrentCultureIgnoreCase)
  • 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-29T22:58:36+00:00Added an answer on May 29, 2026 at 10:58 pm

    How about a string extension method?:

    public static class StringExtensions {
        public static bool EqualsIC(this string self, string string1) {
            return self.Equals(string1, StringComparison.InvariantCultureIgnoreCase);        
        }
    }
    

    Then you can just use

    string string1 = "Hello world";
    string string2 = "hEllO WOrLD";
    bool theymatch = string1.EqualsIC(string2);
    
    // OR (per TimS' comment) - to avoid error if string1 is null
    theymatch = StringExtensions.EqualsIC(string1, string2);
    

    As an esoteric alternative, you could use Regex instead of String.Compare:

    public static bool EqualsICRX(this string self, string string1) {
        return Regex.IsMatch(string1, "^" + self + "$", RegexOptions.IgnoreCase);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the company where I am right now, there are a lot of places
I know I've seen this done a lot in places, but I need something
Folks, this one is killing me.... I'm using jscrollpane in a lot of places
I have a class object that i'm using a lot from different places. Now
For my program I have a lot of places where an object can be
I've read in a lot of places that a set data structure can be
So I have a site where there are a lot of places where html
I have read in a lot of places but I really can't understand the
I have looked in a lot of places but it seems i can't find
I wanted to ask for some help. I know, that there are a lot

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.