What's wrong with this switch/case statement?

Posts   
 
    
NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 25-Jan-2006 20:47:45   

I have the following:

switch (_ha.AppType.ToLower())
                {
                    case "sqlserver":
                        return HlpAppType.SqlServer;
                    case "ad":
                        return HlpAppType.ActiveDirectory;
                    case "exchange":
                        return HlpAppType.Exchange;
                    default:
                        return HlpAppType.None;
                }

yet, when the _ha.AppType string value is "sqlServer" it falls to the default. At what point in the analyzation of that string does the switch happen and at what point does the ToLower() function happen? Does the ToLower happen AFTER the swtich has analyzed which branch to follow?

Edit I suppose I should clarify that the _ha.AppType is a string, yet I'm returning an enumeration type.

NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 25-Jan-2006 20:54:31   

Never mind. It was because the spaces at the end that are returned from SqlServer matter. So, it was comparing "sqlserver " to "sqlserver". And of course, they don't match.