How i can compare type data type in VB.NET? My code:
Private Function Equal(ByVal parameter As String, ByVal paramenterName As String, ByVal dataType As Type) As
The accepted answer has a syntax error. Here is the correct solution:
If dataType = GetType(String) Then
Return 1
End If
Or
If dataType.Equals(GetType(String)) Then
Return 1
End If
Or
If dataType Is GetType(String) Then
Return 1
End If
The last way is probably the best way to check because it won't throw an exception if the object is null.
Also see https://msdn.microsoft.com/en-us/library/system.object.gettype(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1