StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
sw.WriteLine("Name list");
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("content-disposition", "attachment;filename=teamlist.txt");
Response.Flush();
Response.Write(sb);
Response.End();
Wednesday, April 1, 2009
Codes example for why use Lambda: how to find a distinct id list, and pass it into another method
Before Lambda:
List<Person> result = GetFromSomeWhere();
List<string> distinctids= new List<string>();
foreach (Person one in result)
{
if (!distinctids.Contains(one .Id.ToString()))
distinctids.Add(one .Id.ToString());
}
foreach (string id in distinctids)
{
DisplayPerson(id);
}
After:
List<Person> result = GetFromSomeWhere();
var result = result.Select(p=> p.Id).Distinct().ToList() ;
result.ForEach(id=>DisplayPerson(id));
List<Person> result = GetFromSomeWhere();
List<string> distinctids= new List<string>();
foreach (Person one in result)
{
if (!distinctids.Contains(one .Id.ToString()))
distinctids.Add(one .Id.ToString());
}
foreach (string id in distinctids)
{
DisplayPerson(id);
}
After:
List<Person> result = GetFromSomeWhere();
var result = result.Select(p=> p.Id).Distinct().ToList() ;
result.ForEach(id=>DisplayPerson(id));
Tuesday, March 31, 2009
The most important concepts, design pattern, in MVC ASP.NET
It is better to read something about those concepts, otherwise, it will confuse you for a while.
1. MVC design patthern
2. Controller, Action, ViewData, html helpers
3. JQuery
4 StructureMap, Dependency Injection and Inversion of Control
1. MVC design patthern
2. Controller, Action, ViewData, html helpers
3. JQuery
4 StructureMap, Dependency Injection and Inversion of Control
Wednesday, March 25, 2009
How to converts a virtual path to an application absolute path
URL.content(virtual path)
Url.Content("~/Images/sendmail.jpg")
Url.Content("~/Images/sendmail.jpg")
Subscribe to:
Posts (Atom)