Basic List<> syntax inquiry

Jan 18 2014 10:09 PM

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<Order> orderList = datalist();

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<Order> datalist()

{

List<Order> orderList = new List<Order>();

Order o1 = new Order();

o1.OrderID = 123;

return orderList;

}

}

}

//WHEN I RUN THIS EXAMPLE THE CONSOLE WINDOW OPEN WITH BLINKING CURSOR WITHOUT DISPLAYING  Console.WriteLine("Order ID is: {0}", o.OrderID.ToString()); WHAT I AM DOING WRONG

Answers (1)