10.11 Class View and Object Browser

Now that we have introduced key concepts of object-oriented programming, we present two Visual Studio features that facilitate the design of object-oriented apps—the Class View and the Object Browser.

10.11.1 Using the Class View Window

The Class View displays the fields, methods and properties for all classes in a project. Select View > Class View to display the Class View as a tab in the same position within the IDE as the Solution Explorer. Figure 10.12 shows the Class View for the Time1 project of Fig. 10.1 (class Time1) and Fig. 10.2 (class Time1Test).

Fig. 10.12 Class View of class Time1 (Fig. 10.1) and class Time1Test (Fig. 10.2).

The view follows a hierarchical structure, positioning the project name (Time1) as the root and including a series of nodes that represent the classes, variables, methods and properties in the project. If a

appears to the left of a node, that node can be expanded to show other nodes. If a

appears to the left of a node, that node can be collapsed. According to the Class View, project Time1 contains class Time1 and class Time1Test as children. When class Time1 is selected, the class’s members appear in the lower half of the window. Class Time1 contains methods SetTime, ToString and ToUniversalString, indicated by purple boxes

and public properties Hour, Minute and Second, indicated by wrench icons

If a class has any private members, those members’ icons contain small padlocks. Both class Time1 and class Time1Test contain the Base Types node. If you expand this node, you’ll see class Object in each case, because each class inherits from class System.Object—we discuss this concept in Chapter 11.

10.11.2 Using the Object Browser

Visual Studio’s Object Browser lists all classes in the .NET library. You can use the Object Browser to learn about the functionality provided by a specific class. To open the Object Browser, select View > Object Browser. Figure 10.13 depicts the Object Browser when the user navigates to the Math class in namespace System. To do this, we expanded the node for mscorlib (Microsoft Core Library) in the upper-left pane of the Object Browser, then expanded its subnode for System. The most common classes from the System namespace, such as System.Math, are in mscorlib.

Fig. 10.13 Object Browser for class Math.

The Object Browser lists all methods provided by class Math in the upper-right pane—this offers you “instant access” to information regarding the functionality of various objects. Clicking the name of a member in the upper-right pane displays a description of that member in the lower-right pane. The Object Browser can be used to quickly learn about a class or one of its methods. You also can view the complete description of a class or a method in the online documentation by selecting the type or member in the Object Browser and pressing F1.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset