【发布时间】:2018-02-12 19:58:16
【问题描述】:
我有以下代码:
VMware.Vim.Task task = new VMware.Vim.Task(Client,thisDC.MoRef);
foreach(VMware.Vim.Task eachTask in task)
{
lvLogging.Items.Add(eachTask.DescriptionId);
}
但我得到了错误:
foreach statement cannot operate on variables of type 'VMware.Vim.Task' because 'VMware.Vim.Task' does not contain a public definition for 'GetEnumerator'
所以我做了以下事情:
List<VMware.Vim.Task> task = new List<VMware.Vim.Task>();
task = new VMware.Vim.Task(Client,thisDC.MoRef);
但现在我有以下错误:
Cannot implicitly convert type 'VMware.Vim.Task' to 'System.Collections.Generic.List<VMware.Vim.Task>'
我完全迷路了吗? 我要做的是从 ESXi 主机获取任务,然后发送到 ListView。
【问题讨论】: