C # Datatable sorting,
To Sort Datatable in C #, use the Sort method of DefaultView. First, get the DefaultView of the Datatable, then set the sort attribute of the Dataview, and then use the ToTable method of the view to export the sorted dataview as the Datatable.
The Code is as follows:
DataTable dt = new DataTable ();
Dt. Columns. Add ("ID", typeof (int ));
Dt. Columns. Add ("Name", typeof (string ));
Dt. Rows. Add (new object [] {12, "lwolf "});
Dt. Rows. Add (new object [] {100, "kkkkk "});
Dt. Rows. Add (new object [] {19, "jim "});
Dt. Rows. Add (new object [] {1, "test "});
DataTable dtCopy = dt. Copy ();
DataView dv = dt. DefaultView;
Dv. Sort = "ID ";
DtCopy = dv. ToTable ();
In this way, we finally get the sorted Datable.
Symbol in C Language <Yes
Left shift operator (<)
Removes all the binary bits of an operation object from the left and adds 0 to the right ).
For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,
Move 1 to the left and then a = a * 2;
If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)
Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.
The operand shifts one digit to the right, which is equivalent to dividing the number by 2.
For example, a = a> 2 shifts the binary bit of a two places to the right,
0 or 1 to see whether the number is positive or negative.
Symbol in C Language <Yes
Left shift operator (<)
Removes all the binary bits of an operation object from the left and adds 0 to the right ).
For example, a = a <2 shifts the binary bits of a two places to the left and complements 0 to the right,
Move 1 to the left and then a = a * 2;
If the left shift does not include 1 in the Discard high position, then shifts one bit left, which is equivalent to multiplying the number by 2.
Shift right operator (>)
Shifts all the binary bits of a number to several places to the right, and adds 0 to the left of the positive number, 1 to the left of the negative number, and discards the right of the negative number.
The operand shifts one digit to the right, which is equivalent to dividing the number by 2.
For example, a = a> 2 shifts the binary bit of a two places to the right,
0 or 1 to see whether the number is positive or negative.