...
Some Usage Examples
| Code Block |
|---|
// open, print all lines of a text file , close
IOIterators.EachLine(@"c:\dynamic.ini", delegate(string it) {
Console.WriteLine(it);
});
List<string> list = new List<string>();
// populate list
// print a list of string
list.Each(delegate(string it) {
Console.WriteLine(it);
});
System.Collections.Generic.IEnumerable<string> res;
// find all items matching the predicate item.Contaons("8")
res = list.FindAll(delegate(string it) {
return it.Contains("8");
});
// find the first item where Item.Equals("10")
string ten = list.Find(delegate(string it) {
return it.Equals("10");
});
List<int> nums = new List<int>();
for (int j = 1; j < 11; ++j) {
nums.Add(j);
}
// apply a functor ( multiply by 2 ) to a list of ints
nums.Map(delegate(int num) {
return num * 2;
});
|