问一下VS中的代码段不能自动导入命名空间

.Net技术 码拜 9年前 (2015-10-24) 1147次浏览
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>readspace</Title>
			<Shortcut>readspace</Shortcut>
			<Description>读取空格分割的整数</Description>
			<Author>zhangweixiao@live.com</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
		  <References>
        <Reference>
          <Assembly>System.dll</Assembly>
          <Url></Url>
        </Reference>
      </References>
		<Imports>
        <Import>
          <Namespace>System</Namespace>
        </Import>
		 <Import>
          <Namespace>System.IO</Namespace>
        </Import>
         </Imports>
			<Declarations>
				<Literal>
					<ID>num1</ID>
					<ToolTip>第一个值</ToolTip>
					<Default>num1</Default>
				</Literal>
                                 <Literal>
					<ID>num2</ID>
					<ToolTip>第二个值</ToolTip>
					<Default>num2</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp"><![CDATA[
           StreamReader sr = File.OpenText(@"../../data.txt");
string str = null;
while ((str = sr.ReadLine()) != null)
{
str = str.Trim();
while (str.Contains("  "))
str = str.Replace(" ", "");
string[] splitStr = str.Split(new char[] {"" ""});
int $num1$ = Convert.ToInt32(splitStr[0]); 
int $num2$= Convert.ToInt32(splitStr[1]);
]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>

上面代码段,需要用system.io下的类,不能自动导入吗?

也尝试了自带的。

也尝试了系统的office 开发-word里面的代码段,命名空间和引用都需要本人手动添加吗?

解决方案:20分
很遗憾,不能,msdn上说了:

The Namespace element is only supported for Visual Basic projects.


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明问一下VS中的代码段不能自动导入命名空间
喜欢 (0)
[1034331897@qq.com]
分享 (0)