为什么此函数不会在所有代码路径上返回值?

aaa*_*aaa 1 .net vb.net

考虑:

Private Function ViewPropertyCast(ByVal type As String) As String
  Select Case type
    Case "smallint"
      Return "Short"
    Case "nvarchar"
      Return "String"
    Case "int"
      Return "Integer"
    Case "float"
      Return "Double"
    Case "datetime"
      Return "Date"
    Case "bigint"
      Return "Long"
    Case "ntext"
      Return "String"
    Case "bit"
      Return "Boolean"
    Case "uniqueidentifier"
      Return "Guid"
  End Select
End Function
Run Code Online (Sandbox Code Playgroud)

为什么ViewPropertyCast不在所有代码路径上返回值?

pax*_*blo 5

因为如果type没有这些东西上市,它只是下降到不返回任何底部.

尝试类似的东西:

Private Function ViewPropertyCast(ByVal type As String) As String
    Select Case type
        Case "smallint"
            Return "Short"
        Case "nvarchar"
            Return "String"
        Case "int"
            Return "Integer"
        Case "float"
            Return "Double"
        Case "datetime"
            Return "Date"
        Case "bigint"
            Return "Long"
        Case "ntext"
            Return "String"
        Case "bit"
            Return "Boolean"
        Case "uniqueidentifier"
            Return "Guid"
    End Select
    Return "NoIdea"               ' <-- Added this bit '
End Function
Run Code Online (Sandbox Code Playgroud)