Some tips on Visual Studio. NET (1)

Source: Internet
Author: User

1, Comments, or repeatedCodeFragment
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, it would be nice to drag them to the code file.VSIs possible, we just need to select our code block, and then drag this Code directly to the toolbox in code mode. Next, we can drag the "control" directly to our code where we want to comment. Is it cool!

2Format the entire block

We are writing code, or from someone else's Html Paste a section in the source file Html Code sticking to our VS In the design mode, is the format of the original mode unchanged? When writing code, VSWe can arrange it in a very neat format for easy reading, but stick it VS In the design mode Html The Code 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 to make VS For us to do this typographical work, We can edit - Advanced - Click the format of the design document, then our code or HtmlThe layout is neat. 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

3Select a region
InVs. netBy pressingALTIn the left-side navigation pane. 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. In fact, I often use it to make a target search in a specific document section.-The replacement operation, but due to the regular 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, "{< span style =" font-family:; ">" must be marked with the corresponding "}< span style =" font-family:; ">. In vs2005 click {,matched }< span style =" font-family:; "> It is highlighted, but if the code is too long, it cannot be found, similarly, the compiler indicator " # region " must have the corresponding " # endregion " indicator. When you navigate your code, you sometimes need to find the corresponding identifier. Press 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 code between two matched identifiers, press Ctrl-shift-] highlight the entire block and move the cursor to the opened logo. 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. InVs. net. In the text editor, right-click the method name and select to define from the pop-up menu.Vs. netJump to the definition of this method immediately. The default shortcut for this feature isF12.

6 , Practical pre-defined code snippets
Code snippets are popular and pre-defined text templates can be selected by developers rather than manually typed in. For example Foreach Loop, instead of all the code you need, you can simply Foreach . SMART awareness is displayed with a new code snippet icon Foreach Item (see figure ). If you select a piece of code from the smart sensing list, then press Tab , VS Will insert Foreach .

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.
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)


Related Article

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.