What\'s the difference between casting an Int to a string and the ToString() method ?
For example :-
int MyInt = 10;
label1.Text = (string)MyInt;
Well, ToString() is just a method call which returns a string. It's defined in object so it's always valid to call on anything (other than a null reference).
The cast operator can do one of four things:
int to byteobject to string, which checks for the target object being an appropriate typeobject to intIn this case, you're asking the compiler to emit code to convert from int to string. None of the above options apply, so you get a compile-time error.