Protected void Page_Load (object sender, EventArgs e)
{
System. Data. DataTable dt1=new System. Data. The DataTable ();
Dt1. Columns. The Add (" column1 ");
Dt1. Columns. The Add (" column2 ");
Dt1. Rows. The Add (" 3 ", "eight");
Dt1. Rows. The Add (" 8 ", "9");
Dt1. Rows. The Add (" 9 ", "11");
Dt1. Rows. The Add (" 9 ", "13");
Dt1. Rows. The Add (" 13 ", "16");
Dt1. Rows. The Add (" 13 ", "18");
Dt1. Rows. The Add (" 18 ", "20");
Dt1. Rows. The Add (" 18 ", "25");
Dt1. Rows. The Add (" 25 ", "32");
Dt1. Rows. The Add (" 32 ", "36");
Dt1. Rows. The Add (" 32 ", "45");
Dt1. Rows. The Add (" 25 ", "47");
Dt1. Rows. The Add (" 47 ", "49");
Dt1. Rows. The Add (" 47 ", "50");
System. Data. DataTable dtClone=dt1. Copy ();
for (int i=0; I & lt; Dt1. Rows. Count; I++)
{
For (int k=1; K & lt; DtClone. Rows. Count; K++)
{
If (dt1. Rows [I] [r]. "column2" ToString ()==dtClone. Rows [k] [r]. "column1" ToString ())
{
Response. Write (" & lt; Br>" + dtClone. Rows [k] [r]. "column1" ToString () + dtClone. Rows [k] [r]. "column2" ToString () + "& lt; Br>" );
}
}
}
}
Hope to get the results:
Column1 column2
3 8
8 50
9 11
13 16
18 to 20
25 36
32 45
47 to 49
CodePudding user response:
According to what rule, the second group didn't seeCodePudding user response:
Where are you this recursive again?CodePudding user response:
Rules are as follows:Take the second column 8 to find the first column is equal to the value of the 8 8 rows, as in the first column of finding and take the second column 9, to find the value of the first column is equal to 9, due to the line in the first column found 9, 11 go to get the second column, because in the first column is not found 11 lines, will display (9, 11), and then take the second column 13 to find... So on
Dt1. Rows. Add (" 3 ", " ");
Dt1. Rows. Add (" ", "9");
Dt1. Rows. The Add (" 9 ", "11");
Dt1. Rows. The Add (" 9 ", "13");
Dt1. Rows. The Add (" 13 ", "16");
Dt1. Rows. The Add (" 13 ", "18");
Dt1. Rows. The Add (" 18 ", "20");
Dt1. Rows. The Add (" 18 ", "25");
Dt1. Rows. The Add (" 25 ", "32");
Dt1. Rows. The Add (" 32 ", "36");
Dt1. Rows. The Add (" 32 ", "45");
Dt1. Rows. The Add (" 25 ", "47");
Dt1. Rows. The Add (" 47 ", "49");
Dt1. Rows. The Add (" 47 ", "50");
CodePudding user response: