【发布时间】:2022-01-24 18:13:20
【问题描述】:
在 Form2 我有这个变量,我尝试了所有方法,任何修改都会导致错误:
string[] row = {
ProcessName[Index],
process.Id.ToString(),
status,
BytesToReadableValue(process.PrivateMemorySize64),
extraProcessInfo.Username,
extraProcessInfo.Description
};
来自this article,一个自定义的Taskmgr。
我需要将此变量传递给 Form 1,但我无法将其公开,所以我创建了
public static string[] Row;
Row = row;
所以在 Form 1 中,我执行了以下操作:string[] ROW = Form2.Row; 这实际上不会导致错误(是的,如果您问我,这些变量名非常有创意)。
但我需要将 Row 的所有值存储在 ROW 中;我试过了
int Index = 1;
string[] ROW = new string[10];
ROW[Index] = AddForm.Row[];
Index++;
但我经常收到错误“无法将类型'string'隐式转换为'string[]'”。
解决方案: 像这样添加一个 0:AddForm.Row[0]; 这显然很明显,我以为我已经尝试过了,但它奏效了。
【问题讨论】:
标签: c# visual-studio winforms visual-studio-2022