Monday, April 7, 2008

Object and collection initializers

Object initializers:
var data = new ProcessData {Id = 123, Name ="CurrentProcess",Memory = 12345567};
Collectiopn initializers:
var digits = new List {0,1,2,3,4,5};

for example:
foreach (var process in Process.GetProcesses())
{

processes.Add(new ProcessData { Id = process.Id, Name = process.ProcessName, Memory = process.WorkingSet64 });
}


yeah yeah yeah so easy now !!!!!!!!!!!!!!!!!!!!!!

No comments: