Tips for using vs. net

Source: Internet
Author: User

1. Comments or repeated code snippets
When writing code, we often need to write code comments. However, it is not annoying to write the comments in each class. If you copy and paste the comments every time, is it very troublesome, if we want to drag controls and drag them to the code file, it is actually possible in vs. We just need to select our code block, in the code mode, drag the Code directly to the toolbox. Next, we can drag the "control" directly to our code where we want to comment. Is it cool!

2. format the entire block.

When we write code or paste a piece of HTML code from someone else's HTML source file to the design mode in our vs, is the format the original mode? When writing code, VS can be well arranged and easy to read, but HTML code sticking to the vs design mode cannot be guaranteed to have such a format, so that when we look for whether a mark is closed, it is all red and wavy lines, a special headache. Now there is a convenient way for vs To Do This typographical work for us. We can click the design document format from edit-advanced, then our code or HTML is neatly formatted. Shortcut: Ctrl + K + d

(HTML chaos)
After using Ctrl + K + d

Is the current HTML Tag sorted by layers! The same applies to CS code

3. Select a region
In vs. net, press and hold the Alt key to drag the mouse over a rectangle to make a selection. I wonder if you have selected a region like this? This technique allows you to create a region that does not contain rows (see figure ). This method is very easy to copy, cut, and paste rectangular area blocks.

You may be surprised why someone needs this profound feature. As a matter of fact, I often use it to make a target search-replace operation in the previous specific document section, but due to the conventional automatic line feed option, I cannot do this. I believe you will find this feature very convenient.

4. Search for matched tags
Some identifiers are always paired. For example, the "{" identifier must be disabled with the corresponding "}" identifier. Even if you click {In vs2005, the matching} will be highlighted, but if the code is too long, it will be hard to find it. Similarly, the compiler indicator "# region" must have the corresponding "# endregion" indicator. When you navigate your code, you sometimes need to find the corresponding identifier. You can do this by pressing Ctrl. This shortcut key takes effect only when the cursor is under any of these identifiers. It immediately jumps to the corresponding identifier regardless of whether it is an open or closed identifier.
If you want to highlight all the code between two matched identifiers, press Ctrl-shift-] to highlight the entire block and move the cursor to the open identifiers. This shortcut key only works when the cursor is under any logo (for example, it does not work when the cursor is in the area ).

5. Definition of the redirection Method
When you see a method call of your class, you are very likely to look at the method body. In vs. net, context menu is used. In the text editor, right-click the method name and select to define from the pop-up menu. Vs. Net immediately jumps to the definition of this method. The default shortcut for this feature is F12.

6. use predefined code snippets
Code snippets are popular and pre-defined text templates can be selected by developers rather than manually typed in. For example, for foreach loop, you can simply knock foreach instead of all the code you need. Smart sensing uses the new code snippet icon to display foreach items (see figure ). If you select a piece of code from the smart sensing list and press tab, vs inserts a pre-defined piece of code for "foreach.

As friends in the garden constantly introduce some of their skills in Vs, this article is constantly updated. Thank you!
Update
7. Design view and code (CS) file Switch
We are adding. to switch to the background code in the aspx file, right-click the design view and select "view code". We can easily switch to the background code, you can also use the shortcut key F7 to switch between them.
8. custom string case-insensitive Switching
Maybe the title is not exactly named. It means that if we define a string like this:

String strvalue = "aaaaaaa ";

What if we want to change this AAAAA to an uppercase aaaaaa? Delete the file in the rewrite? In fact, a convenient variable is to use Ctrl + Shift + U, which can only be converted to uppercase in lower case. If we convert uppercase to lower case, use Ctrl + U.
2007-10-31
9. Cut and copy the entire row
If we are cutting the entire row, how can we copy or cut it if it is not selected? We can move the cursor to the front of this line, and press Ctrl + X or Ctrl + C to copy and cut the entire line. (Also applies to pasting)

We hope that the above will make it easier for you to write code.

# C # column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.