用C#做了一个冒泡排序,排序的是字符串的东西,代码如下,为什么错误提示:“运算符“<”无法应用于“string”和“string” 类型的操作数 ”
string []p ;
for (int i = 0; i < listView1.Items.Count; i++)
{
p = new string[listView1.Items.Count];
p[i] = listView1.Items[i].Text;
}
string []p ;
for (int i = 0; i < listView1.Items.Count; i++)
{
p = new string[listView1.Items.Count];
p[i] = listView1.Items[i].Text;
}
string temp;
// string[] aa = p;
for (int i = 0; i < p.Length; i++)
{
for (int j = 0; j < p.Length – i – 1; j++)
{
if (p[j + 1] < p[j])
{
temp = p[j];
p[j] = p[j + 1];
p[j + 1] = temp;
}