VS 在创建C#类时添加文件描述

在新建一个C#类时,为了描述该类的功能、以及文件建立的相关信息,并保护自己的版权要在文件的开头添加一些信息。如下:

 1 /*********************************************************************************** 
 2 *        Filename :Class3 
 3 *        Description :  
 4 *        Date:2014/5/15 16:31:29 
 5  *       Machinename:PC-201305061330 
 6 *        Created by: <T> Andy Sun 
 7 *        All rights reserved 
 8 * 
 9 *       ChangeLog: 
10 *       2014/5/15 16:31:29: 
11  *          Created! 
12 ************************************************************************************/  
13 using System;  
14 using System.Collections.Generic;  
15 using System.Linq;  
16 using System.Text;  
17 using System.Threading.Tasks; 

而手动添加即费时又费力,好在vs为我们提供了模版更改接口,下面就来简单介绍一下。

1、首先,要找到C#类模版的所在。一般情况下会是在%VS安装目录%Common7IDEItemTemplatesCacheCSharpCode2052Class(或%VS安装目录%Common7IDEItemTemplatesCSharpCode2052Class)中的class.cs文件。

2、打开该文件,文件头部添加如下信息:

 1 /*********************************************************************************** 
 2 *        Filename :$safeitemrootname$ 
 3 *        Description :  
 4 *        Date:$time$ 
 5  *       Machinename:$machinename$ 
 6 *        Created by: <T> Andy Sun 
 7 *        All rights reserved 
 8 * 
 9 *       ChangeLog: 
10 *       $time$: 
11  *          Created! 
12 ************************************************************************************/  
13 using System;  
14 using System.Collections.Generic;  
15 $if$ ($targetframeworkversion$ >= 3.5)using System.Linq;  
16 $endif$using System.Text;  
17 $if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;  
18 $endif$  
19 namespace $rootnamespace$  
20 {  
21     class $safeitemrootname$  
22     {  
23     }  
24 }  

3、保存文件后,新建C#类时即可看到在文件头部自动添加了相关信息。

原文地址:https://www.cnblogs.com/a-dou/p/6702573.html