What's the point of constraining Tin if it's always going to be a string?
class Test
{
public void Foo<Tout>(string val, Converter<string,Tout> conv)
{
myObj = conv(val);
}
}
Just get rid of the Tin type and use string in your Converter. I think you're over-complicating things.
You cannot use string as a generic constraint as it's a sealed class. This makes perfect sense as nothing can inherit from string so why add a constraint for string?
I.e. If you COULD inherit from string:
public SuperString : string
Then you could use string as a constraint and pass through SuperString as Tin. However you CANNOT do this as string is a sealed class. Therefor the only object you could pass to Tin is String anyway.
Because of this, you may as well get rid of Tin and use the code I wrote above.