Q: List with items returns empty

D: I have created a simple List function but if I Loop through the List it's empty. It should not be!
More details: http://stackoverflow.com/questions/4691530

Test Case #11


File ID: #4691582-1-cc


Process[] processes = Process.GetProcesses();
foreach (Process p in processes) {
    try {
        foreach (ProcessModule module in p.Modules) {
            Console.WriteLine("({0}) ({1}) : {2}", p.ProcessName, p.Id, module.FileName);
        }
    } catch {
    Console.WriteLine("Process id {0:D} exception", p.Id);
    }

  1. Do you really think the `catch {}` is a good idea?
  2. Because it swallows *all* exceptions *silently*: you can not tell when *anything's* gone wrong. a) it's almost always a bad idea to handle all exceptions uniformly; b) it's almost always a bad idea to swallow exceptions, taking no action (not event logging). Doing both at once is a *terrible* idea.
  3. Why just give corrected code without explanation? What will anyone learn from this? The empty catch block is a really bad thing to do - either remove it all together or ensure you do something with any exceptions caught.

Comments Quality
Accurate?:
Precise?:
Concise?:
Useful?: