简体   繁体   English

Visual Studio 2012“ Visual C#类”模板位置

[英]Visual Studio 2012 “Visual C# class” template location

I'm currently able to modify the default class template at the following location: 我目前可以在以下位置修改默认的类模板:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class

This works great when right-clicking on a project and selecting add -> class . 右键单击项目并选择add -> class这非常add -> class

Though, when adding a class through the File menu item of Visual Studio 但是,通过Visual Studio的“ File菜单项添加类时

File -> New -> File... -> Visual C# Class

The class template appears to not work. 该班级模板似乎无法正常工作。 I'm assuming it's at a different location from where I've specified above. 我假设它与上面指定的位置不同。 Where can I find the " Visual C# class " template? 在哪里可以找到“ Visual C#类 ”模板?

Edit: 编辑:

class generated from File->New->File... General -> Visual C# class File->New->File... General -> Visual C# class

using System;

public class Class1
{
    public Class1()
    {
    }
}

class generated from right-clicking on project-> Add Clas s right-clicking on project-> Add Clas的类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Class1
    {

    }
}

As you can see, the classes are different all together, which makes me believe that it is using two different templates. 如您所见,这些类在一起都是不同的,这使我相信它使用的是两个不同的模板。

I'm not entirely sure if this is the same with VS 2012, but I think you can tell VS to regenerate the cache using the command devenv /installvstemplates (provided you run the command as administrator). 我不确定VS 2012是否相同,但是我认为您可以告诉VS使用命令devenv /installvstemplates重新生成缓存(前提是您以管理员身份运行该命令)。

More complete explanation (for VS 2010) here: http://ericsowell.com/blog/2007/5/22/how-to-edit-visual-studio-templates 更完整的说明(针对VS 2010)在此处: http : //ericsowell.com/blog/2007/5/22/how-to-edit-visual-studio-templates

Not so much as an answer to the where, but to the why... 与其说是答案,不如说是为什么……。

It looks like File->New->File doesn't use the template, I have tested this and it's the case with VS2010 too. 看起来File->New->File没有使用模板,我已经测试过了,VS2010也是如此。 On a side note, why don't you use right-clicking on project-> Add Class ? 附带说明一下,为什么不right-clicking on project-> Add Class It works and let's you place the file where you need it to be, note that the other method opens the file, but doesn't add it to the project, merely opens it. 它起作用了,让我们将文件放置在需要的位置,请注意,另一种方法会打开文件,但不会将其添加到项目中,而只是将其打开。 Perhaps that's part of the reason why it is such a basic empty class template. 也许这就是为什么它是一个如此基本的空类模板的部分原因。

To be honest this is the first time I try the other method you mentioned :) 老实说,这是我第一次尝试您提到的其他方法:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM