What is suppose to happen is that I am suppose to take a string like "Micheal Jordan" and reverse it and return it with a comma after the last name. like "Jordan, Micheal" but that is not what i am getting can you help please. I have also included the directions for this part as well.
The public String GetInfoLastNameFirst() method should create a first name string and a last name string from this.name. You must use a loop to create the first name string. You must use a loop to create the last name string. (HINT: we created new strings from old strings in lecture, exercises, and studio of September 22/23.) Then, similarly to the method GetAllInfo(), this method should return all the info about the candidate, but do so with the last name first, followed by a comma, followed by the first name, then tab, then party, then tab, then votes, then new line. You must use a loop, to create the first name and last name strings. (Clever coding can do it with one loop; straightforward coding uses two.)
/// <summary>
/// reverses the first and last name and puts a comma in between
/// </summary>
/// <returns></returns>
public String GetInfoLastNameFirst()
{
string FN = name;
string LN = name;
int i = 0;
int j = 0;
int location = name.IndexOf(" ");
while (i < location)
{
FN = i.ToString() ;
i++;
}
while (j > location)
{
LN = j.ToString();
j++;
}
return LN + ',' + ' ' + FN + "\t" + this.party + "\t" + this.votes + "\r\n";
}