"MyClass" is a placeholder in this code
The code sample you have included is just to illustrate that *any* object instance can call a ToString method. The MyClass type hasn't been defined; it is just a placeholder for some type name of a class that is either part of the .NET framework, or which you have defined somewhere else in your project.
I must admit that the type name chosen (MyClass) is a bit unfortunate, because it's a keyword and couldn't be used as the name of a class in real code. I would have chosen something different (I didn't write this particular chapter).
However, this code was never meant to work as-is - it is just intended to illustrate a minor point, and the experienced reader is expected to understand the need to insert a real class identifier (with an appropriate constructor argument) when using the technique.
Such generic placeholders are not uncommon in snippets, because it takes so long to go through a step-by-step to do a complete example of even a fairly minor point such as usage of ToString. It would have been necessary to go through the entire procedure for defining a simple class just to make a quick point.
Keep in mind that this is a book in the Professional series, so a certain level of coding expertise and experience is assumed. If you feel that you need more detail for illustration of points like this, the Beginning series might be a better choice for you.
|