using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LISTCOLLECTIONS
{
class Program
{
static void Main(string[] args)
{
List
var orders = from o in orderList
select o;
foreach (var o in orders)
Console.WriteLine("Order ID is: {0}", o.OrderID.ToString());
Console.ReadLine();
}
class Order
{ public int OrderID { get; set; } }
static private List
{
List
Order o1 = new Order();
o1.OrderID = 123;
return orderList;
}
}
}
Biswa Pujarini MohapatraPosted Jan 18, 2014, 10:30 PM
you have not added order o1 object to the orderlist in datalist() function
I have modified your code
class Order
{ public int OrderID { get; set; } }
static private List datalist()
{
List orderList = new List();
Order o1 = new Order();
o1.OrderID = 123;
orderList.Add(o1);
return orderList;
}
hope it helps. Please "Mark it as Answer" if it helps