Home > Articles > Programming > Visual Studio

  • Print
  • + Share This
This chapter is from the book

Browsing the Visual Basic and .NET Documentation

The .NET Framework Base Class Library is very large, and remembering all the objects that you can use in your applications (or the ones that .NET Framework relies on) is not possible. What is instead important is to know where to search for information. You have different tools available to browse the .NET Framework and its documentation, for Visual Basic, too. Because the goal of this chapter is to provide information on the primary tools you need for developing Visual Basic applications, getting help with the language and with the tooling is absolutely one of the primary necessities, as discussed next.

Online Help and the MSDN Library

Visual Studio 2012 ships with the MSDN Library, which is the place where you can find documentation for Visual Basic 2012 and the .NET Framework 4.5. There are basically two ways to access the MSDN Library: offline and online. To access the MSDN Library offline, you have the following alternatives:

  • Click the View Help command from the Help menu in Visual Studio.
  • Press F1 from wherever you are.
  • Open the Microsoft Help Viewer shortcut in Windows’s Start, All Programs, Microsoft Visual Studio 2012 menu; this launches the local help viewer.

If you are writing code or performing a particular task on a tool within the IDE, pressing F1 is the best choice because you will be redirected to the help page related to that instruction, code statement, or tool. If you are instead searching for information about a particular technology or framework, such as WPF or the Visual Studio Tools for Office, you could consider one of the other choices. To access the MSDN Library online, you just need an Internet connection. Then you can specify to always use the online help by selecting Help, Set Help Preference and then clicking Launch in Browser or Launch Help Viewer, or you can manually open one of the following websites, which are the main points of interest for a Visual Basic developer:

You can also quickly find information on particular objects using built-in tools, such as the Object Browser.

Object Browser Window

The Object Browser is a special tool window that enables you to browse the .NET Framework class library as well as any referenced libraries and types defined in your projects. You can get a hierarchical view of the Base Class Library and of all the types defined in your solution, including types defined in referenced external assemblies. The Object Browser can be activated by pressing CTRL+ALT+J; it is useful because you can understand how a type is defined, which members it exposes, which interfaces it implements, and which other classes it derives from. If the types are documented, you can get a description for each object or member.

Figure 2.35 represents, as an example, the Object Browser showing members of the System.Windows.ContentElement class.

Figure 2.35

Figure 2.35. The Object Browser enables exploring .NET objects showing information.

The right side of the window lists methods and properties exposed by the selected object. When you click on a method or on a member of the object in the left side of the window, a short description of the object should appear in the bottom-right side of the Object Browser. If the description is not useful enough to understand the meaning of an object or of one of its members, you can press F1, and Visual Studio shows the online help (if available) for the object or member. The Object Browser also provides links to objects used by the one you are exploring. Considering the example shown in Figure 2.35, you not only can see the description of a method, but also can also click the parameters’ identifiers to be redirected to the definition of the parameter. The Object Browser can also be invoked when writing code, as discussed next.

Invoking the Object Browser from the Code Editor

Often you need to know how particular .NET objects or members are structured or how they work. Visual Studio 2012 provides the ability of invoking the Object Browser directly from the code editor by right-clicking the object you want to browse and selecting the Go to Definition command from the pop-up menu. For example, imagine you want to know how the Console class is defined. To accomplish this, you can revisit the MyFirst2012Program example. When in the code editor, right-click the Console object and select Go To Definition. By doing this, Visual Studio opens the Object Browser that automatically selects the Console class, showing its methods on the right side of the screen (see Figure 2.36).

Figure 2.36

Figure 2.36. The Object Browser can be invoked from the code editor by clicking the Go to Definition command.

This technique works with shared classes or, more generally, with declarations of noninstance classes; however, in some situations you might want to learn about data types or instance members’ definitions. For example, consider the following code:

Dim text As String
text = "Hi!"

If you try to run the Go to Definition command for the text identifier, you will be redirected to the first line of code, which effectively defines the text object. But what if you want to browse the String object? Fortunately there is another command you can choose in such situations—Go to Type Definition. It is still available in the pop-up menu. Invoking Go to Type Definition redirects to the definition of the type that characterizes the object you declared (in our example, String). The result will be the same as in Figure 2.36, of course referring to the selected type.

Although the Object Browser’s purpose is not typically to provide help, it is a good place for learning about .NET objects, both if you need information on their structure and if you need descriptions on their usage.

  • + Share This
  • 🔖 Save To Your Account