Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
64 views
in Technique[技术] by (71.8m points)

How do I edit the Visual Studio templates for new C# class/interface?

I find myself removing the following import statements in nearly every C# file I create in Visual Studio:

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

Of course its really easy to do this with Resharper, but I really should not have to.

There must be a few template (class, interface) somewhere in the VS directory, from which I can remove the offending lines. Where do I find these files? Is there a better way to control the default import list?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

2017 through 2019 (current)

Visual Studio 2017 changed the directory location to use release year instead of its internal version number, and is additionally dependent on your edition (Professional/Enterprise/etc.):

%ProgramFiles(x86)%Microsoft Visual Studio <year><edition>Common7IDEItemTemplatesCSharpCode1033Class.cs

Year Edition Absolute path
2019 Community %ProgramFiles(x86)%Microsoft Visual Studio 2019CommunityCommon7IDEItemTemplatesCSharpCode1033Class.cs
Enterprise %ProgramFiles(x86)%Microsoft Visual Studio 2019EnterpriseCommon7IDEItemTemplatesCSharpCode1033Class.cs
Professional %ProgramFiles(x86)%Microsoft Visual Studio 2019ProfessionalCommon7IDEItemTemplatesCSharpCode1033Class.cs
2017 Community %ProgramFiles(x86)%Microsoft Visual Studio 2017CommunityCommon7IDEItemTemplatesCSharpCode1033Class.cs
Enterprise %ProgramFiles(x86)%Microsoft Visual Studio 2017EnterpriseCommon7IDEItemTemplatesCSharpCode1033Class.cs
Professional %ProgramFiles(x86)%Microsoft Visual Studio 2017ProfessionalCommon7IDEItemTemplatesCSharpCode1033Class.cs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...