Doing a college project and I\'m a bit stuck..
Basically, I need to take the string input for an employee name and an integer input for the amount of properties they sol
Ideally you would be using a class for these, as seen in the example below.
public class Owner
{
public string Name { get; }
public int PropertiesSold { get; }
public Owner(string name, int propertiesSold)
{
Name = name;
PropertiesSold = propertiesSold;
}
}
This way you can keep track of the name and # of properties at the same time. Your loop turns into this:
List owners = new List();
for (int i = 0; i < 2; i++)
{
Console.WriteLine("Please enter the employee name: ");
string name = Console.ReadLine();
Console.WriteLine("Please enter the number of Properties Sold: ");
int numProperties = int.Parse(Console.ReadLine());
owners.Add(new Owner(name, numProperties));
}
And you can use Linqs OrderByDescending as seen here to sort the list of Owners. LINQ Orderby Descending Query.