Option Compare Text Not Working!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmarcrum
    New Member
    • Oct 2007
    • 105

    Option Compare Text Not Working!

    I am trying to use Option Compare Text in Visual Studio 2008. Can you not use Option Compare Text at the top of the code in Visual C#? It doesn't recognize it.

    Thanks for your help!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Option Compare Text is VB only and therefor doesn't apply to C#, nor should you be using it in your .NET projects actually. You should have got compiler errors for it

    Comment

    • jmarcrum
      New Member
      • Oct 2007
      • 105

      #3
      I'm not sure that is entirely accurate.. have you investigated before posting? This is my code...

      Code:
      //Get the name of the link to save 
      string origName = fuImgs.FileName;
      string linkName = origName.Replace(".JPG", ".lnk");
      If I put ".JPG" in lowercase ~ ".jpg" it doesn't replace.

      Did you test your theory? I am using Visual Studio 2008 ~ Visual C#

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        If by theory I went to MSDN and checked, then yes.
        "Option" is a vb word. There might be a C# version of it, but I saw no references to it

        Your example had nothing to do with proving or disproving any statement.

        Your initial post was about Compare, String.Compare contains overloads for ignoring case. .Replace does not. You may have to force a case on the string, or do your own custom replace.
        .IndexOf() and .EndsWith() both have the option to ignore case

        Comment

        • jmarcrum
          New Member
          • Oct 2007
          • 105

          #5
          That got it...

          Thanks Plater!

          Code:
          string imgTest = fuImgs.FileName;
          bool answer = imgTest.EndsWith(".jpg", StringComparison.CurrentCultureIgnoreCase);

          Comment

          Working...