Error 1 The best overloaded method match for 'Project_210.BubbleSorter.Sort(object[], Project_210.CompareOp)' has some invalid arguments C:\Documents and Settings\Eddy Ho\Local Settings\Application Data\Temporary Projects\Project-210\Program.cs 67 13 Project-210 Error 2 Argument '2': cannot convert from 'Project_210.Program.CompareOp' to 'Project_210.CompareOp' C:\Documents and Settings\Eddy Ho\Local Settings\Application Data\Temporary Projects\Project-210\Program.cs 67 42 Project-210 using System; using System.Collections.Generic; using System.Text; namespace Project_210 { delegate bool CompareOp(object lhs, object rhs); class BubbleSorter { static public void Sort(object[] sortArray, CompareOp gtMethod) { for (int i = 0; i < sortArray.Length; i++) { for (int j = i + 1; j < sortArray.Length; j++) { if (gtMethod(sortArray[j], sortArray[i])) { object temp = sortArray[i]; sortArray[i] = sortArray[j]; sortArray[j] = temp; } } } } } class Employee { private string name; private decimal salary; public Employee(string name, decimal salary) { this.name = name; this.salary = salary; } public override string ToString() { return string.Format(name + " {0:C)", salary); } public static bool RhsIsGreater(object lhs, object rhs) { Employee empLhs = (Employee)lhs; Employee empRhs = (Employee)rhs; return (empRhs.salary > empLhs.salary) ? true : false; } } class Program { delegate bool CompareOp(object ihs, object rhs); static void Main(string[] args) { Employee[] employees = { new Employee("Karli Watson",20000), new Employee("Bill Gates",10000), new Employee("Simon Robinson",25000), new Employee("Mortime",(decimal)100000), new Employee("Arabe Jones",20000), new Employee("Avon from <code>'</code>;Black's 7'",50000) }; CompareOp employeeCompareOp = new CompareOp(Employee.RhsIsGreater); BubbleSorter.Sort(employees, employeeCompareOp); for (int i = 0; i < employees.Length; i++) Console.WriteLine(employees[i].ToString()); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)