01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Linq;
04.
using
System.Text;
05.
06.
namespace
ConsoleApplication1
07.
{
08.
class
Program
09.
{
10.
class
record
11.
{
12.
public
int
No {
get
;
set
; }
13.
public
string
Name {
get
;
set
; }
14.
public
int
Age {
get
;
set
;}
15.
};
16.
17.
static
void
Main(
string
[] args)
18.
{
19.
var data1 =
new
List<record>();
20.
int
iMax = 5;
21.
22.
Console.Write(
"Employee............"
);
23.
Console.WriteLine();
24.
for
(
int
n = 1; n < iMax; n++)
25.
{
26.
Console.Write(
"Enter name["
+ n +
"] :"
);
27.
String sName = Console.ReadLine();
28.
Console.Write(
"Enter Age["
+ n +
"] :"
);
29.
int
iAge = Convert.ToInt32(Console.ReadLine());
30.
31.
data1.Add(
new
record { No=n, Name = sName, Age = iAge });
32.
}
33.
Console.WriteLine();
34.
Console.Write(
"Output...\n"
);
35.
Console.WriteLine();
36.
37.
38.
var data2 = data1.OrderBy(o => o.Age);
39.
40.
41.
foreach
(var item
in
data2)
42.
{
43.
Console.WriteLine(String.Format(
"No = {0}, Name = {1}, Age = {2}"
, item.No, item.Name, item.Age));
44.
}
45.
46.
Console.Read();
47.
}
48.
}
49.
}