4 using System
.Collections
.Generic
;
11 public int ID { get; set; }
12 public string Name { get; set; }
14 public override string ToString ()
16 return ID
+ " " + Name
;
20 public static int Main ()
22 int[] int_array
= new int [] { 0, 1 }
;
23 string[] string_array
= new string[] { "f", "a", "z", "aa" }
;
27 e
= from int i
in int_array
orderby i
select i
;
29 List
<int> l
= new List
<int> (e
);
36 e
= from int i
in int_array
orderby i
ascending select i
;
38 l
= new List
<int> (e
);
45 e
= from i
in int_array
orderby i
descending select i
+ 1;
46 l
= new List
<int> (e
);
53 IEnumerable
<string> s
;
54 s
= from i
in string_array
orderby i
select i
;
56 List
<string> ls
= new List
<string> (s
);
70 s
= from i
in string_array
orderby i
.Length
select i
;
73 Data
[] data
= new Data
[] {
74 new Data { ID = 10, Name = "bcd" }
,
75 new Data { ID = 20, Name = "Abcd" }
,
76 new Data { ID = 20, Name = "Ab" }
,
77 new Data { ID = 10, Name = "Zyx" }
80 var de
= from i
in data
orderby i
.ID
ascending, i
.Name
descending select i
;
82 List
<Data
> ld
= new List
<Data
> (de
);
83 if (ld
[0].Name
!= "Zyx")
86 var de2
= from i
in data
orderby i
.ID
descending, i
.Name
ascending select i
;
87 ld
= new List
<Data
> (de2
);
88 if (ld
[0].Name
!= "Ab")
91 var de3
= from i
in data
93 orderby i
.ID
descending, i
.Name
ascending select i
;
94 ld
= new List
<Data
> (de3
);
95 if (ld
[0].Name
!= "bcd")
98 var de4
= from i
in data
100 orderby i
.Name
group i by i
.Name
;
102 var group_order
= new List
<IGrouping
<string, Data
>> (de4
);
103 ld
= new List
<Data
>(group_order
[0]);
105 if (ld
[0].Name
!= "Ab")
108 ld
= new List
<Data
>(group_order
[1]);
109 if (ld
[0].Name
!= "Abcd")
112 Console
.WriteLine ("OK");