I want to convert a string to a generic type like int or date or long based on the generic return type.
Basically a function like Parse<T>(String) that returns an item of type T.
For example if a int was passed the function should do int.parse internally.
System.Convert.ChangeType
As per your example, you could do:
To satisfy your “generic return type” requirement, you could write your own extension method:
This will allow you to do: