2009-06-22 209 views
10

有谁知道我可以在Visual Studio 2008代码片段中插入当前日期&时间的方式吗?我想在我的是.snippet文件的正文是这样的......在Visual Studio片段中插入当前日期时间

<Code Language="csharp"> 
    <![CDATA[ 
    // $DateTime$ 
    // more code here for my snippet... 
    </Code> 

回答

18

有可用的片断没有日期时间函数,但这里是将插入当前日期时间的宏:

Sub PrintDateTime() 
    If (Not IsNothing(DTE.ActiveDocument)) Then 
     Dim selection As TextSelection = DTE.ActiveDocument.Selection 
     selection.Insert(DateTime.Now.ToString()) 
    End If 
End Sub 

您可以使用Alt + F8打开您的宏指令浏览器,并创建一个新模块并将上面的代码粘贴到生成的模块中。

然后创建一个新的键盘快捷方式并将其绑定到您的宏。

+0

C#Express有没有解决方案? – 2009-07-20 15:10:07

相关问题