有谁知道我可以在 visual studio 2008 片段中插入当前日期和时间的方法吗?我想要的是我的 .snippet 文件正文中的类似内容...
<Code Language="csharp">
<![CDATA[
// $DateTime$
// more code here for my snippet...
</Code>
最佳答案
没有可用于片段的 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
您可以使用 Alt + F8 打开宏资源管理器并创建一个新模块并将上面的代码粘贴到生成的模块中。
然后创建一个新的键盘快捷键并将其绑定(bind)到您的宏。
关于c# - 在 Visual Studio 片段中插入当前日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1029189/