Visual Studio C# Code Editor

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

How to create a new code file

1. Open Visual Studio. Press Esc or click Continue without code on the start window to open the development environment. 2. From the File menu on the menu bar, choose New > File, or press Ctrl+N. 3. In the New File dialog box, under the General category, choose Visual C# Class, and then choose Open. A new file opens in the editor with the skeleton of a C# class. (Notice that we don't have to create a full Visual Studio project to gain some of the benefits that the code editor offers; all you need is a code file!)

An even quicker way to get the definition of a type or method that doesn't move your focus away from the file you're working in is to

use Peek Definition

How to comment out code

1. Paste the following code into the Main() method body. 2. We're not using the morewords variable, but we may use it later so we don't want to completely delete it. Instead, let's comment out those lines. Select the entire definition of morewords to the closing semi-colon, and then choose the Comment out the selected lines button on the toolbar. If you prefer to use the keyboard, press Ctrl+K, Ctrl+C. The C# comment characters // are added to the beginning of each selected line to comment out the code.

How to add a code snippet

1. Place your cursor just above the final closing brace } in the file, and type the characters svm(which stands for static void Main—don't worry too much if you don't know what that means). A pop-up dialog box appears with information about the svm code snippet. 2. Press Tab twice to insert the code snippet. You see the static void Main() method signature get added to the file. The Main() method is the entry point for C# applications. The available code snippets vary for different programming languages. You can look at the available code snippets for your language by choosing Edit > IntelliSense > Insert Snippet or pressing Ctrl+K, Ctrl+X, and then choosing your language's folder.

How to refactor a name

1. Place your cursor over the definition of the _words variable, and choose Rename from the right-click or context menu, or press Ctrl+R, Ctrl+R. A pop-up Rename dialog box appears at the top right of the editor. 2. Enter the desired name words. Notice that the reference to words in the query is also automatically renamed. Before you press Enter, select the Include comments checkbox in the Rename pop-up box. 3. Press Enter. Both occurrences of words have been renamed, as well as the reference to words in the code comment.

Let's peek at the definition of the string type.

1. Right-click on any occurrence of string and choose Peek Definition from the content menu. Or, press Alt+F12. A pop-up window appears with the definition of the String class. You can scroll within the pop-up window, or even peek at the definition of another type from the peeked code. 2. Close the peeked definition window by choosing the small box with an "x" at the top right of the pop-up window.

How to collapse a code block

Choose the small gray box with the minus sign inside it in the margin of the first line of the constructor. Or, if you're a keyboard user, place the cursor anywhere in the constructor code and press Ctrl+M, Ctrl+M.

What is Intellisense?

a coding aid that displays a list of matching methods, amongst other things

Solution

a container that's used to organize one or more related code projects

SQL Server Object Explorer in Visual Studio provides

a view of your database objects similar to SQL Server Management Studio. It also enables you to do light-duty database administration and design work.

Visual Studio's modular installer enables you to

choose and install workloads

To expand the code block again,

click the same gray box that now has a plus sign in it, or press Ctrl+M, Ctrl+M again

This feature called Outlining is useful for

collapsing long methods or entire classes

You can also use IntelliSense to

complete a word after you type enough characters to disambiguate it

Workloads

groups of features needed for the programming language or platform you prefer

What can Intellisense show you?

information about available members of a type, or parameter details for different overloads of a method

The Visual Studio editor makes it easy to inspect the definition of a type, method, etc. One way is to

navigate to the file that contains the definition, for example by choosing Go to Definition or pressing F12 anywhere the symbol is referenced

Toolbar

the row of buttons under the menu bar in Visual Studio

What are code snippets used for?

to quickly and easily generate commonly used code blocks


Kaugnay na mga set ng pag-aaral

Cohesion, Adhesion, and Surface Tension

View Set

Sternocleidomastoid and Trapezius Muscles

View Set

Chapter 34: Organization and Control of Neural Function-Patho taken from http://thepoint.lww.com/Book/Show Level 3

View Set

Chapter 14: The Movement to Objects

View Set

Life: (2:1) Completing the Application, Underwriting, and Delivering the Policy

View Set

Quality Control and Quality Assurance

View Set

ISDS Module 3 Computer Concepts Test

View Set

Pathophysiology: Chapter 7 Stress and Adaptation

View Set