public void ReArrange()
{
string[] List = { "Red",
"White", "Red",
"White", "White",
"White", "Red",
"Red", "White"
};
string temp;
for (int i = 0; i
< List.Length; i++)
{
if (List[i] == "White")
{
for (int
j = i; j < List.Length; j++)
{
if (List[j] == "Red")
{
temp = List[i];
List[i] = List[j];
List[j] = temp;
break;
}
}
}
}
foreach (var item in List)
{
Response.Write(item);
}
}
No comments:
Post a Comment