我想知道为什么这段代码在 C++/CLI 中不起作用,但在 C# 中却很容易?
List<Process^>^ processList = gcnew List<Process^>(
Process::GetProcessesByName(this->processName)););
错误 C2664: 'System::Collections::Generic::List::List(System::Collections::Generic::IEnumerable ^)' : 无法将参数 1 从 'cli::array ^' 转换为 'System::Collections ::Generic::IEnumerable ^'
这是我想出的。做得非常好。:)
List<Process^>^ processList = gcnew List<Process^>(
safe_cast<System::Collections::Generic::IEnumerable<Process^>^>
(Process::GetProcessesByName(this->processName)));