The namespace zz
{
Class Program
{
The static void Main (string [] args)
{
Var em=Sort (new Employee [] {new Employee (" a ", 71), a new Employee (" b ", 66), a new Employee (" c ", 761), a new Employee (78), "d"});
Foreach (var e in em)
{
Console. WriteLine (e.N ame + "wage is" + e.S alary. The ToString ());
}
}
The static Employee [] Sort (Employee [] the Employee)
{
Bool mark=true;
While (mark)
{
for(int i=0; I
If (the employee [I] Salary> [I + 1]. The employee Salary)
{
Var temp=employee [I];
The employee [I]=employee [I + 1);
The employee [I + 1)=temp;
}
The else mark=false;
}
}
Return the employee;
}
}
The class Employee
{
Public string Name;
Public int Salary;
Public Employee (string name, int salary)
{
This. Name=Name;
This. Salary=Salary;
}
}
}
CodePudding user response:
Is there a more simple and concise wayCodePudding user response:
Var em=new Employee [] {new Employee (" a ", 71), a new Employee (" b ", 66), a new Employee (" c ", 761), a new Employee (78), "d"};
Em=em. OrderBy (e=& gt; E.S alary). ToArray ();
CodePudding user response:
Linq syntax look at: https://www.tutorialsteacher.com/linq/linq-sorting-operators-orderby-orderbydescendingCodePudding user response:
E=& gt; E.N ameWhat is meaning of parameters is e, the return value is e.N ame a delegate?
CodePudding user response: