Thursday, 3 March 2011

Chapter 2 Introduction to Visual Studio IDE(for C#)

The development environment provided by Microsoft for C# is one of the best IDE if not the best. This product is a trend setter and all other IDE's try to copy its features. It is so rich in feature that it is hard to enumerate each and every little tricks it has. To understand this environment you have to do it yourself. Best part of the IDE is user can change it and customize it according to his/her needs.
Some of the most important Tools you might require for C# are all available under the view menu.
  • The Code Editor, for writing source code.
  • The C# compiler, for converting C# source code into an executable program.
  • The Visual Studio debugger, for testing your program.
  • The Toolbox and Designer, for rapid development of user interfaces using the mouse.
  • Solution Explorer, for viewing and managing project files and settings.
  • Project Designer, for configuring compiler options, deployment paths, resources, and more.
  • Class View, for navigating through source code according to types, not files.
  • Properties Window, for configuring properties and events on controls in your user interface.
  • Object Browser, for viewing the methods and classes available in dynamic link libraries including .NET Framework assemblies and COM objects.
  • Document Explorer, for browsing and searching product documentation on your local machine and on the Internet.

Editor and Windows Form Designer Windows


The large main window is used by both the Code Editor and the Windows Forms Designer. You can toggle between code view and Design view by pressing F7, or clicking Code or Designer on the View menu. While in Design view, you can drag controls onto the window from the Toolbox, which you can make visible by clicking on the Toolbox tab on the left margin.

The Visual C# Code Editor is a word processor for writing source code. Just as Microsoft Word provides extensive support for sentences, paragraphs, and grammar, the C# Code Editor does the same for C# syntax and the .NET Framework. This support can be grouped into five main categories:
  • IntelliSense:Continually updated basic documentation on .NET Framework classes and methods as you type them in the editor, as well as automatic code generation.
  • Refactoring:Intelligent restructuring of your code base as it evolves over the course of a development project.
  • Code snippets: A library you can browse that contains frequently repeated code patterns.
  • Wavy underlines: Visual notifications of misspelled words, erroneous syntax, and warning situations as you type.
  • Readability aids: Outlining and colorization.

IntelliSense

IntelliSense is the name of a set of related features that are designed to minimize the time you spend looking for help and to help you enter code more accurately and efficiently. These features all provide basic information about language keywords, .NET Framework types, and method signatures as you type them in the editor. The information is displayed in ToolTips, list boxes, and smart tags.

Completion Lists

As you enter source code in the editor, IntelliSense displays a list box that contains all the C# keywords and .NET Framework classes. If it finds a match in the list box for the name that you are typing, it selects the item. If the selected item is what you want, you can simply hit TAB and Intellisense will finish entering the name or keyword for you. For more information, see Completion Lists in C#.

Quick Info

When you hover the cursor over a .NET Framework type, IntelliSense will display a Quick Info ToolTip that contains basic documentation about that type.

List Members


When you enter a .NET Framework type into the Code Editor, and then type the dot operator (.), IntelliSense displays a list box that contains the members of that type. When you make a selection and press TAB, IntelliSense enters the member name.

Parameter Info

When you enter a method name in the Code Editor, and then type an opening parentheses, IntelliSense will display a Parameter Info ToolTip that shows the order and types of the method's parameters. If the method is overloaded, you can scroll down through all the overloaded signatures.


Add usings


Sometimes you may attempt to create an instance of a .NET Framework class without a sufficiently qualified name. When this happens, IntelliSense displays a smart tag after the unresolved identifier. When you click the smart tag, IntelliSense displays a list of using directives that will enable the identifier to be resolved. When you select one from the list, IntelliSense adds the directive to the top of your source code file and you can continue coding at your current location.

Refactoring

As a code base grows and evolves over the course of a development project, it is sometimes desirable to make changes in order to make it more readable to humans, or more portable. For example, you may want to split some methods up into smaller methods, or change method parameters, or rename identifiers. The Refactoring feature, which is accessible by right-clicking in the Code Editor, does all this in a way that is much more convenient, intelligent, and thorough than traditional tools such as search and replace.

Code Snippets

Code snippets are small units of commonly used C# source code that you can enter accurately and quickly with only a couple of keystrokes. The code snippet menu is accessed by right-clicking in the Code Editor. You can browse from among the many snippets provided with Visual C#, and you can also create your own.

Wavy underlines

Wavy underlines give you instant feedback on errors in your code as you type. A red wavy underline identifies a syntax error such as a missing semicolon or mismatched braces. A green wavy underline identifies a potential compiler warning, and blue identifies an Edit and Continue issue. The following illustration shows a red wavy underline:



Readability Aids

Outlining

The Code Editor automatically treats namespaces, classes, and methods as regions that you can collapse in order to make other parts of the source code file easier to find and read. You can also create your own collapsible regions by surrounding code with the #region and #endregion directives.



Colorization

The editor gives different colors to the various categories of identifiers in a C# source code file.


The Properties window in the lower right is populated only in Design view. It enables you to set properties and hook up events for user interface controls such as buttons, text boxes, and so on. When you set this window to Auto Hide, it will collapse into the right margin whenever you switch to Code View.

Solution Explorer and Project Designer

The window in the top right is Solution Explorer, which shows all the files in your project in a hierarchical tree view. When you use the Project menu to add new files to your project, you will see them reflected in Solution Explorer. In addition to files, Solution Explorer also displays your project settings, and references to external libraries required by your application.

The Project Designer property pages are accessed by right-clicking on the Properties node in Solution Explorer, and then clicking Open. Use these pages to modify build options, security requirements, deployment details, and many other project properties.

Compiler, Debugger, and Error List Windows


The C# compiler has no window because it is not an interactive tool, but you can set compiler options in the Project Designer. When you click Build on the Build menu, the C# compiler is invoked by the IDE. If the build is successful, the status pane displays a Build Succeeded message. If there were build errors, the Error List window appears below the editor/designer window with a list of errors. Double-click an error to go to the problem line in your source code. Press F1 to see Help documentation for the highlighted error.

The debugger has various windows that display values of variables and type information as your application is running. You can use the Code Editor window while debugging to specify a line at which to pause execution in the debugger, and to step through code one line at a time.

Customizing the IDE

All of the windows in Visual C# can be made dockable or floating, hidden or visible, or can be moved to new locations. To change the behavior of a window, click the down arrow or push-pin icons on the title bar and select from among the available options. To move a docked window to a new docked location, drag the title bar until the window dropper icons appear. While holding down the left mouse button, move the mouse pointer over the icon at the new location. Position the pointer over the left, right, top or bottom icons to dock the window on the specified side. Position the pointer over the middle icon to make the window a tabbed window. As you position the pointer, a blue semi-transparent rectangle appears, which indicates where the window will be docked in the new location.

No comments:

Post a Comment