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. You say you “need” to assign it that way ... what's wrong with an explicit constructor or a call to a static method? Or perhaps the extension method ( ToUser) on string?
source
share