【发布时间】:2015-08-21 18:56:07
【问题描述】:
我正在尝试对 5 个客户对象进行排序,并使用客户 ID 订单对它们进行排序,同时仍保留客户的姓名和欠款总额。我不确定如何使用 ID 号进行排序,同时仍保留与 ID 关联的客户名称和总数。我应该创建string[] arrayOfString {} 吗?我已经设置好了,就位了,客户也做了。
public class Customer
{
//Attributes
private string firstName;
private string lastName;
private int idNumber;
private double total;
//Methods
public Customer() { }
public Customer(string aFirstName, string aLastName, int aIDNumber, double aTotal)
{
this.SetFirstName(aFirstName);
this.SetLastName(aLastName);
this.SetIDNumber(aIDNumber);
this.SetTotal(aTotal);
Console.WriteLine(this.Display());
}
//Set
public void SetFirstName(string aFirstName)
{
this.firstName = aFirstName;
}
public void SetLastName(string aLastName)
{
this.lastName = aLastName;
}
public void SetIDNumber(int aIDNumber)
{
this.idNumber = aIDNumber;
}
public void SetTotal(double aTotal)
{
this.total = aTotal;
}
//Get
public string GetFirstName()
{
return this.firstName;
}
public string GetLastName()
{
return this.lastName;
}
public int GetIDNumber()
{
return this.idNumber;
}
public double GetTotal()
{
return this.total;
}
public string Display()
{
return string.Format("Customer Created\r\n" +
"\tName: {0} {1}\r\n" +
"\tID: {2}\r\n" +
"\tBalence: {3}\r\n", this.GetFirstName(), this.GetLastName(), this.GetIDNumber(), this.GetTotal());
}
【问题讨论】:
-
请出示您的代码。
-
你为什么不把你的代码放在问题中?
-
为什么要让我们猜测您的代码是什么样的?我们可能会猜错并给您错误的答案。那会浪费我们的时间,让我们少考虑你。
-
你真的不希望我们少考虑你。
-
对不起,我是新手
标签: c# arrays sorting multidimensional-array