本文介绍了有没有一种方法可以自动创建使用参考来创建代码段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在c#中创建了一个简单的代码段,并添加了行
I created a simple code snippet in c# which add the line
Debug.WriteLine("");
现在,下一步就是使用代码片段自动创建
now the next step would be, when you use the snippet, to autocreate
using System.Diagnostic;
有什么方法可以自动创建引用?
我尝试通过以下方式设置代码段参考和导入元素:
is there any way to automatically create the reference?I tried and set the snippets Reference and Import elements this way:
<Snippet>
<References>
<Reference>
<Assembly>System.dll</Assembly>
</Reference>
</References>
<Imports>
<Import>
<Namespace>System.Diagnostic</Namespace>
</Import>
</Imports>
.
.
.
</Snippet>
但不起作用
推荐答案
游戏有点晚了,但是现在对C#才有效:)
A little late to the game, but this does work for C# now :)
<References>
<Reference>
<Assembly>System.dll</Assembly>
</Reference>
</References>
<Imports>
<Import>
<Namespace>System.Diagnostic</Namespace>
</Import>
</Imports>
将它们放入< Snippet>
部分。
文档甚至提到(这也适用于C#。)。
PS:如果要添加多个导入,请执行以下操作:
PS: if you want to add more than one import, do it like this:
<Imports>
<Import>
<Namespace>System.Diagnostic</Namespace>
</Import>
<Import>
<Namespace>System.Reflection</Namespace>
</Import>
</Imports>
这篇关于有没有一种方法可以自动创建使用参考来创建代码段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!