Closed Thread
Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: case sensitive

  1. #11
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: case sensitive

    Nope.

    Here is a shortened version:

    Code:
    string s1 = "YEs";
    string s2 = "YES";
    if (s1.ToLower() == s2.ToLower()) {
    //They match
    }
    Making it the same length. Also, in your method, n00bs might not know why you are comparing the value returned to zero, or what the boolean parameter you supply is.

    Therefore, my one is much better. You fail, lulz.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #12
    Jordan Guest

    Re: case sensitive

    lol, n00bs are taught that method in school when they learn .NET, as it is the proper method.

    You are just arguing to increase your contest points. I believe I have seen you use my method before.

    Posted via CodeCall Mobile

  4. #13
    Althaz is offline Newbie
    Join Date
    Nov 2008
    Posts
    15
    Rep Power
    0

    Re: case sensitive

    Obviously all of those work, if you know the string you want to compare thing to, you don't need to create a variable just to compare (I'm pretty sure, the program I made today seems to work, so I suspect this is right).

    eg:

    Code:
    string input = HeresSomethingIPreparedEarlier();
    if (input.ToLower() == "cake")
        return "pie";
    I suspect some of those other functions are there so Java programmers feel more comfortable (eg: in Java you have to use .equals() when comparing a variable string (eg string cake = "pie") to a constant (eg: "pie").
    Last edited by Althaz; 11-21-2008 at 04:34 AM. Reason: lol, left the closing bracket off the if statement...n00bish.

  5. #14
    Jordan Guest

    Re: case sensitive

    You guys should read:

    Will Asrari - String.Compare() versus String.Equals()

    then take a look at: New Recommendations for Using Strings in .NET 2.0

    Read some of the string comparison methods. In particular this Official MS statement about ToUpper and ToLower:

    Users should most certainly be careful when using these functions, since forcing a string to a certain case is often used as a small normalization for comparing strings irrespective of case. If so, consider using a case-insensitive comparison.
    I still stand by my original statement that you should use String.Compare and pass the third operator to ignore case. Pass the fourth operator as the current/local language and your strings work internationally.

    If you wanted to compare a variable against a known string:

    Code:
    if (String.Compare(input, "cake", true) == 0) {....}

  6. #15
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: case sensitive

    Quote Originally Posted by Jordan View Post
    lol, n00bs are taught that method in school when they learn .NET, as it is the proper method.

    You are just arguing to increase your contest points. I believe I have seen you use my method before.

    Posted via CodeCall Mobile
    Incorrect on both counts. First, the contest has finished. Secondly, I have never used string.Compare() before in my memory. You fail, lulz.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

Closed Thread
Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Is MySQL case sensitive?
    By yooj in forum Database & Database Programming
    Replies: 5
    Last Post: 01-24-2011, 11:45 AM
  2. Replies: 5
    Last Post: 10-27-2010, 12:25 AM
  3. switch case
    By kenex in forum C and C++
    Replies: 3
    Last Post: 02-01-2009, 08:18 PM
  4. Help with case
    By kresh7 in forum Visual Basic Programming
    Replies: 5
    Last Post: 03-16-2008, 11:42 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts