1
I’m trying to get just the name of an element of a array. I want to get the name of the first element of array and also the name of the last element. I put my method in the class Carreira
public override string ToString()
{
return "Carrer: " + NrCarreira + "\n1st stop: " + VecParagem.First() + "\nlast stop: " + vecParagem.Last();
}
At the event click 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 from the first and last element of the array. I just want a value.
What I need to change in my method ToString()
?
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site (when you have enough score).
– Maniero