How to write this in better way?

Posted by dario on Stack Overflow See other posts from Stack Overflow or by dario
Published on 2010-04-06T18:39:37Z Indexed on 2010/04/06 18:43 UTC
Read the original article Hit count: 177

Hi all. Let's look at this code:

IList<IHouseAnnouncement> list = new List<IHouseAnnouncement>();
var table = adapter.GetData(); //get data from repository object -> DataTable

if (table.Rows.Count >= 1)
{
    for (int i = 0; i < table.Rows.Count-1; i++)
    {
        var anno = new HouseAnnouncement();
        anno.Area = float.Parse(table.Rows[i][table.powierzchniaColumn].ToString());
        anno.City = table.Rows[i][table.miastoColumn].ToString();
        list.Add(anno);
    }
  }
  return list;

Is it better way to write this in less code and better fashion (must be :-) )? Maybe using labda (but let mi know how)?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about c#

Related posts about design-patterns