Process notepadProcess = new Process(); ProcessStartInfo notepadProcessStartInfo = new ProcessStartInfo("notepad.exe"); notepadProcess.StartInfo= notepadProcessStartInfo; notepadProcess.Start(); System.Threading.Thread.Sleep(1000); ProcessModuleCollection processModuleCollection = notepadProcess.Modules; foreach(ProcessModule processModule in processModuleCollection) { }What I don't know and the course video does not say is why the steps to store the modules collection to a variable is required.
Process notepadProcess = new Process(); ProcessStartInfo notepadProcessStartInfo = new ProcessStartInfo("notepad.exe"); notepadProcess.StartInfo= notepadProcessStartInfo; notepadProcess.Start(); System.Threading.Thread.Sleep(1000); foreach (ProcessModule processModule in notepadProcess.Modules) { }If there a .Net reason for doing it this way? this is just one example, but there are lots through the samples of whenever there is a collection to address it is first stored to a variable.