Convert value from string to generic type that is either Guid or int
If T
will either be Guid
or Int32
then it's not really very generic, is it? Just write two methods instead - either with different names, or possibly overloads. I don't see the benefit in using generics here, and it may very well make your code more complicated than it needs to be.