Prev | Current Page 259 | Next

Satheesh, N Kumar

"LINQ Quickly"

Let us define a new item object with properties including a list,
which contains the list of ingredients for the item.
public class NewItem
{
public string Category { get; set; }
public string Name { get; set; }
public List Ingredients { get; set; }
public double Price { get; set; }
}
Now define a method to create a list of items using the new object.
private static List GetNewItemsList()
{
List itemsList = new List {
new NewItem
{
Category="Icecreams", Name="Chocolate Fudge Icecream",
Ingredients = new List {"cream", "milk", "mono and
diglycerides"},
Price=10.5
},
new NewItem
{
Category="Icecreams", Name="Vanilla Icecream",
Ingredients= new List {"vanilla extract", "guar gum",
"cream"},
Price=9.80
},
new NewItem
{
Category="Icecreams", Name="Banana Split Icecream",
Ingredients= new List {"Banana", "guar gum", "cream"},
Price=7.5
}
};
return itemsList;
}
In the above method you can see a list of strings, Ingredients, within the
itemsList.


Pages:
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
kominek Tango Olsztyn śmieszne dowcipy życzenia ślubne katalog stron