2
I created a list in which I added 2 strings:
var lista = new List<string> {cliente.Nome, cliente.Sobrenome};
And in the end I wanted you to show it like this:
Console.WriteLine(lista[0]);
But just show the name, why?
2
I created a list in which I added 2 strings:
var lista = new List<string> {cliente.Nome, cliente.Sobrenome};
And in the end I wanted you to show it like this:
Console.WriteLine(lista[0]);
But just show the name, why?
2
Because you are only having the first element printed, if you want to print the two elements you need to have it explicitly printed. So:
WriteLine(${lista[0] - lista[1]});
Note that he is not writing the name, he is writing element 0 of array. You know it’s a name, but he doesn’t know, to him it’s just a string whichever.
It’s just a little weird wanting to put age as a string
. Probably this whole idea is wrong, it doesn’t seem like you need a list there, but I can’t say without a bigger context.
This is also pretty weird, adding a list to itself?
lista.AddRange(lista);
I put in the Github for future reference.
Something tells me there must be several other errors in the code.
Browser other questions tagged c# .net list
You are not signed in. Login or sign up in order to post.