是否可以在C#.exe中创建一个字符串并在PowerShell中使用此字符串?
是.
你的问题很模糊 - 你是否使用powershell脚本从c#程序集创建一个对象,然后使用该对象?如果是这样,只需将属性设置为您想要的字符串,然后从powershell正常访问它.
或者,如果它是静态方法,您可以调用它
[My.Assembly.Type]::GetSomeString()
Run Code Online (Sandbox Code Playgroud)
如果你正在运行c#exe,你只需用writeline输出它,PowerShell就会把它拿起来:
.\myexe.exe > $someVar
Run Code Online (Sandbox Code Playgroud)
或者,您可以将其编写为cmdlet,并且您的c#代码可以参与管道.
归档时间: |
|
查看次数: |
194 次 |
最近记录: |