Quickly modify and rename the namespace of the. NET program in batches (1)

Source: Internet
Author: User

In actual projects, we sometimes encounter the need to modify the namespace because of Project reconstruction. In addition to modifying one class, most of them will be renamed by batch replacement. I encountered this problem again yesterday. the method I found on the Internet says that we should resharper to rename it. so I installed this tool and tried it on vs2008 and found that it could indeed be done. However, I tried it later. Without it, the vs tool can also be used for batch renaming, but there are restrictions.

The following two methods can be used if your namespace is just a single word. b. the C format can only be modified in a segment. You can change the first method to. b. c, but cannot be changed back to. b. The second method can only modify the last section C.If you want to completely modify the namespace, we recommend that you use resharper to rename it.. The latest version of resharper is 6.0 on the official website http://www.jetbrains.com/resharper /. For more information, see http://www.cnblogs.com/tianyaxiang/archive/2011/07/05/2098261.html.

Method 1: open a class to be modified in the project, right-click to refactor-Rename

Method 2:

1. Open the project, select the class library you want to change, and then select the menuView-Class View

 

2. Check the Class View to see the namespace of the class under the project.

 

3. Select the namespace to be renamed and right-click to rename

 

4. enter a new namespace

 

5. Click Application

 

Select "yes" and rename again.

 

That is, the modification is complete, and the namespace of all classes is renamed, which is so simple.

 

It is more efficient than batch replacement and is not prone to errors. You can use it for your own learning and only make a record.

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.