1,自己建立Templates,比如公司对接口及类又特殊的要求,如类加什么注释,至少省略了一次copy,paste。我拿代码举例子:
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5)using System.Linq;
$endif$using System.Text;
namespace $rootnamespace$
{
///<summary>
/// 功 能: $safeitemrootname$
/// 作 者: anders lu
/// 创建时间: $time$
/// 修正履历:
/// 修正时间:
///</summary>
class $safeitemrootname$
{
}
}
实现方法很简单,可以copy出来vs自带的Templates,做完修改后,放到"我的文档\Visual Studio 2008\Templates\ItemTemplates\Visual C#"下就可以了,这样在新建类的时候,可以选择这个模板,就可以生成符合公司要求的类了。2、代码段的合理使用,也可以很大程度的提高工作效率,vs自带的就有很多,SnippetDesigner是一款vs2008的插件,可以方便的把自己常用的代码制作成代码段,保存成snippet文件,存放到“我的文档\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets”就可以了,我以方法的注释举例子:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>类/接口/方法的注释(不待参数及返回值)</Title>
<Author>anders</Author>
<Description>
描述信息
</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>zs
</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>UserName</ID>
<ToolTip>用户名</ToolTip>
<Default>anders lu</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp"><![CDATA[ ///<summary>
/// 功 能:
/// 作 者: $UserName$
/// 创建时间:
/// 修正履历:
/// 修正时间:
///</summary>]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>这样在写代码的时候,输入“zs”连续敲击两次tab键就可以把我刚才定义的代码段带出来。
3、使用vs2008的宏,提高工作效率,详细请参见我之前写的偏文章点击打开链接
vs2008 提高编程效率的几点小方法
最新推荐文章于 2024-02-12 00:15:00 发布