+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 11 to 15 of 15

Thread: case sensitive

  1. #11
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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. #12
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    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

  3. #13
    Newbie Althaz is an unknown quantity at this point
    Join Date
    Nov 2008
    Posts
    15

    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 06:34 AM. Reason: lol, left the closing bracket off the if statement...n00bish.

  4. #14
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    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) {....}

  5. #15
    Xav
    Xav is offline
    Code Slinger Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav has much to be proud of Xav's Avatar
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,210
    Blog Entries
    13

    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

+ Reply to Thread
Page 2 of 2
FirstFirst 1 2

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Switch Statement
    By ahmed in forum C and C++
    Replies: 3
    Last Post: 11-07-2008, 04:57 PM
  2. Worst case analysis
    By Chinmoy in forum C Tutorials
    Replies: 5
    Last Post: 10-03-2008, 10:40 AM
  3. Replies: 11
    Last Post: 06-09-2008, 10:52 AM
  4. Please help me
    By yonghan in forum Visual Basic Programming
    Replies: 4
    Last Post: 05-13-2008, 02:08 PM
  5. Is MySQL case sensitive?
    By yooj in forum Database & Database Programming
    Replies: 1
    Last Post: 08-28-2007, 07:45 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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