System.Text.StringBuilder sb = new System.Text.StringBuilder();
31 sb.Append("<h1>List As Is</h1> using ForEach<br/> ");
32 sb.Append("<br/><ul>");
33 ninjas.ForEach(delegate(Ninja n)
34 {
35 sb.Append(String.Format("<li>{0}, ({1})</li>", n._name, n._age));
36 });
37 sb.Append("</ul><br/>");
38
39 ///////////////////////////////////////
40 sb.Append("<h1>Age is greater or equal to 0</h1>using FindAll,and foreach<br/> ");
41 sb.Append("<br/><ul>");
42 List<Ninja> thoseAlive = ninjas.FindAll(delegate(Ninja n)
43 {
44 return n._age >= 0;
45 });
46 thoseAlive.ForEach(delegate(Ninja n)
47 {
48 sb.Append(String.Format("<li>{0}, ({1})</li>", n._name, n._age));
49 });
50 sb.Append("</ul><br/>");
No comments:
Post a Comment