What is the 'c' for in this Select Case block

GrexD

Well-known member
Joined
Mar 5, 2008
Messages
95
Programming Experience
Beginner
This is a chunk of code that came in an ftp sample I downloaded from Microsoft. I've never seem the lower case 'c' used after the case select string. What is it for? In VS2010 the "u"c all shows up in red as if it were a string literal, but the c is outside the quotes.

Greg

VB.NET:
                   Select Case ArgChars(1)
                        Case "?"c
                            do_usage = True

                        Case "u"c
                            If (len > 2) Then
                                len = len - 2
                                szUri = New String(ArgChars, 2, len)
                            Else
                                fNeedUri = True
                            End If

                        Case "f"c
                            If (len > 2) Then
                                len = len - 2
                                szFileToUpload = New String(ArgChars, 2, len)
                            End If

                        Case "p"c
                            If (len > 2) Then
                                len = len - 2
                                szProxy = New String(ArgChars, 2, len)
                            Else
                                fNeedProxy = True
                            End If

                        Case "m"c
                            If (len > 2) Then
                                len = len - 2
                                szMethod = New String(ArgChars, 2, len)
                            Else
                                szMethod = "dir"
                            End If

                        Case "k"c
                            If (len > 2) Then
                                If (ArgChars(2) = "u"c) Then
                                    If len > 3 Then
                                        len = len - 3
                                        szCredentials = New String(ArgChars, 3, len)
                                    Else
                                        do_usage = True
                                    End If
                                End If
                                '
                                ' these are credentials for the actual Ftp server
                                '
                            ElseIf (ArgChars(2) = "p"c) Then
                                '
                                ' these are credentials for the intervening proxy server
                                '
                                If (len > 3) Then
                                    len = len - 3
                                    szProxyCredentials = New String(ArgChars, 3, len)
                                Else
                                    do_usage = True
                                End If
                            End If

                        Case "v"c
                            fPassive = True
                        Case Else
                            Console.WriteLine("Unknown cmdline option: " + Args(i))
                            do_usage = True
                    End Select
 
I thought it was something like that but it seems that is self evident because of the quotes.
 
I thought it was something like that but it seems that is self evident because of the quotes.
The quotes just mean String type. A string contains Char values, and act as a Char array.
 
The quotes just mean String type. A string contains Char values, and act as a Char array.

I get that, going back to my days of C programming. I'm missing something here, though. Is it because ArgChars() is a char array and not a string array?
 
ArgChars may be a Char array or a String, both can be indexed the same way where each element is a Char value. That it is used as parameter to the String constructor like that could indicate that it is really a Char array, unless Option Strict is off. In latter case the code will also be valid at runtime since String can be converted to Char array, but with Option Strict on you would have to explicitly convert a String to a Char array for example with the ToCharArray method or just CType it.
It would not be possible for ArgChars to be a String array in that code.
 
Back
Top