Let's get a little faster with Visual Studio skills, Visual Studio

Source: Internet
Author: User

Let's get a little faster with Visual Studio skills, Visual Studio

They are just inconspicuous tips. Over time, they make our work and learning more efficient, and let us focus more on the logic itself. They are good friends of. NET programmers. They are tips of Visual Studio ...... Do we really know them?

If you want to learn these skills as soon as possible, open Visual Studio and try these skills yourself.

(Image from Bing)

Faster code writing

How to quickly create a class? Create an application and find an empty space that can be used to create a class. Try this:Class <Tab>.

Don't worry. This skill is not complete yet. Enter the expected class name and press Enter.

Frequently create attributes? TryProp <tab>.

Often write foreach statements? TryForeach <tab>

Frequently write console applications? TryCw <tab>

 

What if there are multiple highlight areas? Use Tab to jump.

How to find other Code Snippets? Try the context menu or shortcut key.

 

Faster namespace operations

I often write file-related operations, but the tragedy found that System. IO is not in the default reference namespace? Haha, try this. EnterFile + <ESC> + Ctrl +. + <Enter>.

Okay, this combination looks a little complicated. Let's look at the decomposition action. Once it becomes a muscle memory, everything will become so natural.

First,File + <ESC>, Input class name File, <ESC> is used to eliminate the Completion List. At this time, we can see that there is a small blue small block in the lower left corner of the File. This small block indicates that a Smart Tag is available;

Then,Ctrl +.Used to open SmartTag. Generally, adding using is the first option.

Finally,<Enter>The first item of the application.

Exception: this technique is not applicable to extension methods.

 

Streamline and orderly namespaces

Well, if you want to minimize the number of referenced names and sort them alphabetically after writing your class, you can use the following combination:<Application> + <o> + <a>.

Don't know<Application>Which key is it? I don't know. I 'd like to borrow a name from here. The one on the left of the right Ctrl key is used to call up the context menu key.

 

Make inheriting abstract classes and implementing interfaces faster

There is an abstract class with N abstract methods. When the abstract class is inherited, rewriting these method names is time-consuming, laborious, and boring-like copying method names. Why not let Visual Studio do it?

Copy and paste the following code to Visual Studio for your convenience:

    public abstract class Person
    {
        public abstract void Walk();
        public abstract void Eat();
    }
 
    class Baby : Person
    {
    }

Then place the cursor on the Person behind the Baby and see the Smarttag? ThenCtrl +. + <Enter>Right.

This method also applies to interfaces.

 

Make renaming faster

Is a short variable name often used for laziness? Some teams do not allow short names as variable names, but the full names are too long. In this case, you can write short names and rename them directly. For example, some teams do not allow single-letter variables, such as I:

for (int i = 0; i < 100; i++)
{
    System.Console.WriteLine(i + 1);
}

First, useFor <tab>Generate the for statement, and then useCw <tab>To generate the WriteLine statement.

Then, move the cursor behind the first I and enter ndex.

What are the small parts of the SmartTag prompt?Ctrl +. + <Enter>

 

Conclusion

In addition to referencing the namespace for sorting, we only have access to two shortcut keys:

<Tab>

Ctrl +.

The former is mainly used to insert code snippets, and the latter is used to call SmartTag.

 

These are not advanced technologies, but they are the skills used every day when writing code. With these tips, I believe they will be worn by water.

These skills cannot help you write better Code. However, after you get used to it, it can speed up code writing, this gives us more time to improve code quality.

Little knowledge is dangerous.

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.