Coding New Types

One of the most important new features in the Visual Studio 2010 IDE is the ability to generate on-the-fly objects that do not exist yet. This feature is known as Generate From Usage. To understand how it works, simply create a new Console application named GenerateFromUsage and within the Main method type the following code:

image

Because the Person class has not been implemented, the Visual Basic compiler throws an exception, offering the usual pop-up button that suggests solutions. But with Visual Basic 2010 things change; now you have additional solutions, as shown in Figure 18.1.

Figure 18.1 New error correction options for Visual ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.