PDA

View Full Version : C#.NET Program With LINQ Query


bennielor
26th August 2011, 08:02 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication8
{
class order
{
int ordid;
private int cusid;
private double cost;
public int OrdID
{
get { return ordid; }
set { ordid = value; }
}
public int CusID
{
get { return cusid; }
set { cusid = value; }
}
public double Cost
{
get { return cost; }
set { cost = value; }
}
}
class Program
{
static void Main(string[] args)
{
var Orders = new List<order>
{
new order{OrdID=1,CusID=1466,Cost=2453.67},
new order{OrdID=2,CusID=4566,Cost=5553.78},
new order{OrdID=3,CusID=1768,Cost=1344.35},
new order{OrdID=4,CusID=1775,Cost=4565.34},
new order{OrdID=5,CusID=1456,Cost=9069.78},
new order{OrdID=6,CusID=2562,Cost=3245.39}
};
var found = from o in Orders
where o.CusID == 2562
select new { o.Cost, o.OrdID };
foreach (var res in found)
Console.WriteLine(res.OrdID.ToString() + " " + res.Cost.ToString());
}
}
}
.........
Find Latest Job Openings (http://www.phpjobz.com/)