Sco*_*vey 11 c# visual-studio-2008 code-snippets
有谁知道我可以在visual studio 2008片段中插入当前日期和时间的方式?我想要的是在我的.snippet文件的主体中是这样的......
<Code Language="csharp">
<![CDATA[
// $DateTime$
// more code here for my snippet...
</Code>
Run Code Online (Sandbox Code Playgroud)
And*_*are 18
片段没有可用的DateTime函数,但这里是一个将插入当前DateTime的宏:
Sub PrintDateTime()
If (Not IsNothing(DTE.ActiveDocument)) Then
Dim selection As TextSelection = DTE.ActiveDocument.Selection
selection.Insert(DateTime.Now.ToString())
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
您可以使用Alt+ 打开宏资源管理器F8并创建一个新模块,并将上面的代码粘贴到生成的模块中.
然后创建一个新的键盘快捷方式并将其绑定到您的宏.