I've learned to use implicit operators for my classes.
Now I want to do something like this:
public static implicit operator string(int val)
{
return "The value is: " + val.ToString(); // just an nonsense example
}
However this is wrong. Compiler says:
User-defined conversion must convert to or from the enclosing type
How can I workaround this?
My goal is to be able to run code like this:
int x = 50;
textbox1.Text = x; // without using .ToString() or casting
option strict.