我的代码需要在ArrayList中更改原始对象值。以下是代码的工作原理,但我不相信它会改变原始对象的值。
Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "ffmpeg.exe";
startInfo.Arguments = "...";
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = true;
startInfo.CreateNoWindow = true;
process.OutputDataReceived += Process_OutputDataReceived;
process.ErrorDataReceived += Process_ErrorDataReceived;
process.EnableRaisingEvents = true;
process.StartInfo = startInfo;
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
我想要一种代码来保证在ArrayList中修改检索到的对象。任何帮助表示赞赏!
答案 0 :(得分:1)
您可以使用ArrayList.set()
设置给定索引的值。修改对象后,将对象设置为索引:
pairedSystems.set(i, sys)