小编d58*_*884的帖子

如何在其他Add-Type类型定义中访问Add-Type定义的类型?

如何访问Add-Type -TypeDefinition "..."另一个定义的类型Add-Type -TypeDefinition "..."

在下面的代码示例中,尽管名称空间相同,但编译器无法找到该UserCode类型.

Add-Type -TypeDefinition @"
namespace SampleCode {
    public struct UserCode {
         public string Name;
         public string Id;
    }
}
"@

#.... do something ....

Add-Type -TypeDefinition @"
namespace SampleCode {
    public struct UserInformation {
        public UserCode User;
        public string Note;
    }
}
"@
# => Error ... Add-Type : <temporary source path>(3) : The type or namespace name
# 'UserCode' could not be found (are you missing a using …
Run Code Online (Sandbox Code Playgroud)

powershell

5
推荐指数
1
解决办法
7210
查看次数

标签 统计

powershell ×1