What you want to do is override the class whose ToString () you want to implement. The int type is a private class, since most base types.
What you can do is a class that encapsulates an int, and then implements casting operations and overrides the ToString () method.
It sounds like a lot of work for something so small, but it's the way to go!
Here is your class (sorry for the lousy names):
struct b { int myInt; public override string ToString() { return myInt != 0 ? myInt.ToString() : ""; } public static implicit operator int(bd) { return d.myInt; }
source share