Anonymous Types

image_pdfimage_print
   
 

using System;
using System.Collections.Generic;
using System.Diagnostics;

class MainClass{
    static void DisplayProcesses(Func<Process, Boolean> match) {
        var processes = new List<Object>();
        foreach (var process in Process.GetProcesses()) {
            if (match(process)) {
                processes.Add(new {
                    process.Id, Name = process.ProcessName,
                    Memory = process.WorkingSet64
                });
            }
        }
    }

    static void Main(string[] args) {
        DisplayProcesses(process => process.WorkingSet64 >= 20 * 1024 * 1024);
    }
}

    


This entry was posted in LINQ. Bookmark the permalink.