求救
using System;
using System.Collections.Generic;
using System.Text;
namespace DelegetFrom
{
class BubbleSorter
{
public static void Sort(object [] sortArray, CompareOP op)
{
for (int i = 0; i < sortArray.Length; i++)
{
for (int j = 0; j < i; j++)
{
if (op(sortArray[i], sortArray[j]))
{
object temp = sortArray[i];
sortArray[i] = sortArray[j];
sortArray[j] = (Employee)temp;
}
}
}
}
}
class Employee
{
string name;
int salary;
public Employee(string n, int s)
{
this.name = n;
this.salary = s;
}
public override string ToString()
{
return this.name;
}
public static bool CompareDelegate(object lhs, object rhs)
{
Employee lhsEmp = (Employee)lhs;
Employee rhsEmp = (Employee)lhs;
return (rhsEmp.salary > lhsEmp.salary) ? true : false;
}
}
delegate bool CompareOP(object lhs, object rhs);
class Program
{
static void Main(string[] args)
{
Employee[] employee ={
new Employee("sikewe",0),
new Employee("zhouhongyan",100),
new Employee("s",50000),
new Employee("z",0)
};
CompareOP employeeOp = new CompareOP(Employee.CompareDelegate);
BubbleSorter.Sort(employee, employeeOp);
for (int i = 0; i < employee.Length; i++)
{
Console.WriteLine(employee[i].ToString());
}
Console.Read();
}
}
}
求解怎么没排序呢、、、谢谢。。帮忙看看 各位