locked
Case Sensitivity Change RRS feed

  • Question

  • User-3999293 posted

    This is a strange problem I'm having.   Server team just installed .NET 3.x on our development servers and for some reason it's affecting our .NET 1.1 apps.  It looks like it's changing the string object to case sensitive.  (BTW I'm using VB.NET).

     

    .NET 1.1 Code

    Dim response as String = "y"

    If response = "Y" Then

        Do Something

    Else

       Do Something Else

    End If

     

    It's jumping into the else every time.  It never did this before.

     

    Any suggestions???

     

    Thanks,

    Kyle


     

    Thursday, June 19, 2008 2:14 PM

Answers

  • User-1824631895 posted

    The problem here is not the language. Case sensitivity in programming languages does not apply to string literals but to identifiers,types and the likes. In this case, "y" is a string literal and remember that the ASCII value for 'y' is different to that of 'Y'. try changing the code to something like this:  

    1    if String.Compare(r,"Y",true) = 0 Then
    2      ........
    3    else
    4      ........
    

    The third argument in String.Compare tells the runtime to ignore case-sensitivity.

    That should solve the problem.ps

    Remember to mark as answer if it answers your question.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 20, 2008 11:49 AM

All replies

  • User653228039 posted

    I use .Net v 1.x for all my apps and it's always been case-sensitive, though I use C#, maybe VB is different?  Anyway, you can use the String.Compare function.  It has an optional 3rd boolen parameter for "ignore case".

    http://msdn.microsoft.com/en-us/library/zkcaxw5y.aspx

     

    How much code overhaul are we talking here?

    Thursday, June 19, 2008 2:23 PM
  • User-3999293 posted

    Thanks for the response!

     To my knowledge VB.NET was case insensitive.  That's why the code has been working for the past couple years.

    I was praying for a solution that didn't have me changing code all over the place or just a reasoning to why the code is now acting differently than it did before. 

    Thanks Again,

    Kyle

    Thursday, June 19, 2008 2:34 PM
  • User653228039 posted

    Yeah, I'm not sure then.  If it is something that was changed between the different versions of .NET, I'm not sure there is much you can do about it without changing the code.  I'm also not familiar with Visual Studio and what control you have over how your codebehind is compiled, but in my case, I would probably try re-compiling with an older version of .NET.  Newer versions, as far as I know are backward compatible.  But I've had some troubles getting different apps running on different versions of .NET to play nicely in the same yard.

    Thursday, June 19, 2008 2:38 PM
  • User-1824631895 posted

    The problem here is not the language. Case sensitivity in programming languages does not apply to string literals but to identifiers,types and the likes. In this case, "y" is a string literal and remember that the ASCII value for 'y' is different to that of 'Y'. try changing the code to something like this:  

    1    if String.Compare(r,"Y",true) = 0 Then
    2      ........
    3    else
    4      ........
    

    The third argument in String.Compare tells the runtime to ignore case-sensitivity.

    That should solve the problem.ps

    Remember to mark as answer if it answers your question.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 20, 2008 11:49 AM