I have a generic method that copies values between value types. The following approaches give a design time error, even with the struct constraint. Any idea how I can copy or cast between the values?
private Ttgt MyMethod<Tsrc,Ttgt>(Tsrc SourceObject)
where Tsrc:struct
where Ttgt:struct
{
//Error:cannot implictly convert type 'Tsrc' to 'Ttgt'
Ttgt returnObject = SourceObject;
//Error:Cannot convert type 'Tsrc' to 'Ttgt'
Ttgt returnObject = (Ttgt)SourceObject;
return returnObject;
}