I'm trying to get only the name of an element from an array . I want to get the name of the first element of the array and also the name of the last element. I put my method in class Carreira
public override string ToString()
{
return "Carrer: " + NrCarreira + "\n1st stop: " + VecParagem.First() + "\nlast stop: " + vecParagem.Last();
}
In the click event I have this:
Paragem[] vec1 = new Paragem[3];
vec1[0] = new Paragem(1, "Nome1", "Porto");
vec1[1] = new Paragem(2, "Nome2", "Maia");
vec1[2] = new Paragem(3, "Nome3", "Matosinhos");
Carreira c1 = new Carreira(4, true, true, vec1);
label5.Text = c1.ToString();
But I get the career number that is correct, but also all the information in the first and last element of the array . I just want a value.
What do I need to change in my ToString()
method?