I have a string type to be assigned to owner of type 'User'. My method GetFullName returns the name in a 'string' format and i need to assign it to owner of type 'User'
def.Owner = uf.GetFullName(row["assignedto"].ToString());
Any suggestions would be helpful,
So you need something like:
public class User
{
...
public static implicit operator User(string x)
{
return new User(x);
}
}
Personally, I'm not a fan of implicit conversions, however. You say that you "need" to assign it this way... what's wrong with an explicit constructor or static method call? Or perhaps an extension method (ToUser) on string?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With