c# - C# 获取要转换为 PSObject 的数组
问题描述
我正在尝试使用 System.Management.Automation 命名空间来使用 c# 中来自 PowerShell 的内置 gridviewer,但是我似乎无法让它显示我的项目列表,它总是将其返回为一行就像我试图获取数组的信息而不是它的成员一样。
SomeClass[] list; //let's say I have a simple array of one object type
PowerShell posh = PowerShell.Create();
posh.AddCommand("Out-Gridview");
posh.AddArgument(list); //this inputs the list as first argument for the command
posh.Invoke(); //this now just opens a gridview with information about the list itself (length, syncroot, ...)
所以我想要一种将我已经存在的列表转换为我的 C# 代码中的 powershell 兼容对象的方法,最好只使用自动化库和其他默认的 .NET 类。
解决方案
推荐阅读
- pine-script - 如何比较 PineScript 中的两个高点
- javascript - 如何使用 `ngx-cookie-service` 设置 Cookie 的过期时间
- algorithm - 使用不断变化的数组
- hive - 如何使用 Presto/Trino 物理删除数据?
- sql-server - 优化实体框架查询
- python-3.x - 如何更改 html 表单字段映射到 DRF 中的串行字段值?
- docker - 是否可以根据操作系统中安装的 CUDA 驱动程序选择特定的 docker 映像?
- dataframe - 过滤多索引级别的列
- python - 熊猫计算总值的百分比,其中总值是每个唯一列的值
- python - 在 Python 3.8 中赋值之前获取错误局部变量 XXXX