I am wondering which is more efficient, using CStr() or object.toString(). The reason I ask this is because I though all that CStr() done was to invoke the .ToString() method on the object it was dealing with.
But when recently using a generic method without any type constraints I had to use object.ToString() instead of CStr(object), the following is purely an example to illustrate the issue.
Public Function IDFromObject(Of ID_TYPE)(ByVal value As ID_TYPE) As String
Return value.ToString
End Function
Compiled as expected, but the following did not using CStr(). It gave an compilation error value of type ID_TYPE cannot be converted to string. But it obviously can using .ToString()
Public Function IDFromObject(Of ID_TYPE)(ByVal value As ID_TYPE) As String
Return CStr(value)
End Function