C
CSharper
I was following an example of silverlight and I ran into a problem
when I executed the linq
http://www.silverlightshow.net/items/introduction-to-the-datagrid-control-in-silverlight-2.aspx
List<Nutrition> data = ( from nutrition in nutritionsDoc.Descendants
( "Nutrition" )
select new Nutrition
{
Group = nutrition.Attribute
( "Group" ).Value,
Name = nutrition.Attribute
( "Name" ).Value,
Quantity = nutrition.Attribute
( "Quantity" ).Value
} ).ToList();
if I understood correct, I do not need to define the class Nutrition
before hand since it will be treated as anonymous class. But the
compiler fails with Nutrition class reference is missing.
Please correct me if my understanding is wrong.
when I executed the linq
http://www.silverlightshow.net/items/introduction-to-the-datagrid-control-in-silverlight-2.aspx
List<Nutrition> data = ( from nutrition in nutritionsDoc.Descendants
( "Nutrition" )
select new Nutrition
{
Group = nutrition.Attribute
( "Group" ).Value,
Name = nutrition.Attribute
( "Name" ).Value,
Quantity = nutrition.Attribute
( "Quantity" ).Value
} ).ToList();
if I understood correct, I do not need to define the class Nutrition
before hand since it will be treated as anonymous class. But the
compiler fails with Nutrition class reference is missing.
Please correct me if my understanding is wrong.