The first question makes no sense. Let's say that there was an operator 'foo' that got the "name" of a variable. You would have to use it like this in code:
vb.net Code:
Dim varName As String = foo(myVar)
You would have to supply the variable itself to get the name anyway, so what's the point of getting the name in a string when you had to type the name anyway. You'd just do this:
vb.net Code:
Dim varName As String = "myVar"
The second question is more reasonable, although you wouldn't use that method signature:
vb.net Code:
Private Function GetObjectType(ByVal obj As Object) As String
Dim message As String
If TypeOf obj Is Integer Then
message = "It's an Integer"
ElseIf TypeOf obj Is Double Then
message = "It's a Double"
Else
message = "It's something else"
End If
Return message
End Function
That said, you can also use the GetType method of any object to get a Type object that represents its type. The Type class is the basis for most reflection operations.
vb.net Code:
Dim typeName As String = obj.GetType().ToString()
Dim message As String = "It's a " & typeName.Substring(typeName.LastIndexOf("."c) + 1)
MessageBox.Show(message)