【问题标题】:Insert current datetime in Visual Studio Snippet在 Visual Studio Snippet 中插入当前日期时间
【发布时间】:2010-11-04 23:27:52
【问题描述】:

有谁知道我可以在 Visual Studio 2008 sn-p 中插入当前日期和时间的方法吗?我想要的是我的 .sn-p 文件正文中的类似内容...

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

【问题讨论】:

    标签: c# visual-studio-2008 code-snippets


    【解决方案1】:

    sn-ps 没有可用的 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 打开宏浏览器并创建一个新模块并将上面的代码粘贴到生成的模块中。

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

    【讨论】:

    • C# Express 有什么解决方案吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    • 2017-04-01
    • 1970-01-01
    • 2019-05-14
    • 1970-01-01
    相关资源
    最近更新 更多