Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# t4“;使用;关键词_C#_C# 4.0_T4 - Fatal编程技术网

C# t4“;使用;关键词

C# t4“;使用;关键词,c#,c#-4.0,t4,C#,C# 4.0,T4,我是t4新手 我想生成代码到cs文件。 我创建了一个新的tt文件 <#@ template debug="false" hostspecific="false" language="C#" #> <#@ output extension=".cs" #> class IOperation { <# OperationSection section = null; #> } 类操作{ } OperationSection是同一程序集中的一个类。 我假

我是t4新手

我想生成代码到cs文件。 我创建了一个新的tt文件

<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".cs" #>

class IOperation {

<#
OperationSection section = null;

#>
}

类操作{
}
OperationSection是同一程序集中的一个类。 我假设我应该使用“using”关键字

我怎么做? 现在我收到一个错误

编译转换时出现错误2:找不到类型或命名空间名称“OperationSection”(是否缺少using指令或程序集引用?)

谢谢

您需要为中的命名空间
操作节添加一个指令。它们看起来像这样:

<#@ import namespace="System" #>

使用指令:

<#@ import namespace="YourNamespace" #>
<#@ assembly name="$(SolutionDir)\MyProject\bin\Debug\SomeLibrary.Dll" #>