[求助]怎样自定义一个新建类的代码模板?
在一个项目中选择“项目->添加类”时,输入“class1.cs”,会自动生成下面的代码: using System; namespace <项目名称>
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
} 怎么才能重新定义这个类的模板(或者能在“添加新项”对话框中增加一个新的模板),加上我自己的特定内容呢?比如: //----- author: <> ---------
//----- date: <>---------
using System; namespace <项目名称>
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
}
在一个项目中选择“项目->添加类”时,输入“class1.cs”,会自动生成下面的代码: using System; namespace <项目名称>
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
} 怎么才能重新定义这个类的模板(或者能在“添加新项”对话框中增加一个新的模板),加上我自己的特定内容呢?比如: //----- author: <> ---------
//----- date: <>---------
using System; namespace <项目名称>
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class Class1
{
public Class1()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
}
}
解决方案 »
- JAVA代码转成C#
- 学了Dos的C++能不能直接学C#?
- 怎么给webform换skin?????
- .netframework打包
- 会员登陆判断cookie和session的问题
- 100分---Assembly 动态加载后(app1),不退出应用程序如何卸载(app1),紧急求,谢谢
- 急,关于自定义验证控件的问题!
- 如何动态的实现数据报表和数据库的连接?数据报表是不是和数据库连接后,不能改变?
- c#语法问题
- 服务器端的c#怎样才能读写客户端的文件。--以后还会加分
- 怎样在linux中Mono平台上的GtkSharp程序上实现Win下的GridView显示效果来显示Mysql中带图片的表
- 模拟打开某个网页的操作
选择Item Template——选择你要做模板的类——然后按向导一步一步完成。完成后你在项目中添加item的时候,会在最下面的My Templates中看到你刚建的模板类
回符的好:)
现在有个问题是:我这个建好模板后,我希望每次加载模板时能够动态的获得author,date的信息,如下
//----- author: <zhangsu> ---------
//----- date: <8-20>---------
这个信息应该是从操作系统,或者.config配置文件,或者是从vss中获得。
请问:这种在模板中动态的读取数据的功能怎么实现?
谢谢
不知道net2005是否支持这个的功能,或者各位大侠是否能够找出实现这个功能的方法
谢谢
你说的方法应该怎么实现 如何操作“使用IDE的宏来操作,就是打开宏代码编辑器,编写一个使用于IDE的宏命令” 希望多加指点 谢谢
/// Class1 的摘要说明。
/// </summary>
public class Class1
{
.......
}
楼主说的是不是智能感应里头的注释?如果是的话,只需要在类或方法的上面用以下格式,然后调用的时候就会有提示了。
/// <summary>
/// 自定义的说明..
/// </summary>
//----- date: <$time$>---------
$username$和$time$是2个参数.
clrversion
Current version of the common language runtime (CLR).
GUID [1-10]
A GUID used to replace the project GUID in a project file. You can specify up to 10 unique GUIDs (for example, guid1).
itemname
The name provided by the user in the Add New Item dialog box.
machinename
The current computer name (for example, Computer01).
projectname
The name provided by the user in the New Project dialog box.
registeredorganization
The registry key value from HKLM\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization.
rootnamespace
The root namespace of the current project. This parameter is used to replace the namespace in an item being added to a project.
safeitemname
The name provided by the user in the Add New Item dialog box, with all unsafe characters and spaces removed.
safeprojectname
The name provided by the user in the New Project dialog box, with all unsafe characters and spaces removed.
time
The current time in the format DD/MM/YYYY 00:00:00.
userdomain
The current user domain.
username
The current user name.
year
The current year in the format YYYY.
“只需要在类或方法的上面用以下格式,然后调用的时候就会有提示了”
能举个例子吗? 谢谢------------------------------------------------
他说的是xml的注释,不是你要找的那...
输入三个/