1
How do I make a multidimensional list, and that I can add elements like this:
List<List<String>> listaMultidimensional = new List<List<string>>();
listaMultidimensional[0][0].Add ("maca");
listaMultidimensional[0][1].Add ("banana");
listaMultidimensional[1][3].Add ("limão");
What I can do is:
listaMultidimensional[0].Add("maca");
This would be to add "stretcher" in the first row in the first column, but how do I add "stretcher" in the second column ([0][1]) for example? And then how to access the data from a specific row and column of that list?
In this case I recommend that you use Datatable.
– Ícaro Dantas
This doesn’t make much sense, try to improve your question, show what you’re trying to do, show where you’re going.
– Maniero
I understood what he meant, take the pendant off.
– Ícaro Dantas
You can understand yes, it’s simple what I asked, I don’t think I would need an example.
– Moribundo Chat
With the accepted answer it is more evident that it is not clear. The question speaks in list, the answer speaks in
DataTable
, are things so different that only by divination it would be possible to answer this. To tell you the truth I think the answer doesn’t even answer what he really wanted, as he’s still learning he’s clinging to what was posted. The question together with the answer will bring difficulties to a person who is learning who will find that list andDataTable
it’s all the same.– Maniero
I also understood your question and would answer with one more option if it had not been closed :-/ Datatable is a complete object structure, especially useful for allowing data editing in user controls and sending these changes back to the database, because its lines store versions of the data, it supports constraints, relationships with other datatables, notifies editing events, etc. Another solution option would be for you to make your own data structure, with a search feature, something simpler than Datatable.
– Caffé
I initially wanted to use the list, but it would be more complicated using the list, if there is a better way I do not see why not use. Someone coming to do this for a list, will find the topic and know that with Datatable would be best option in this case.
– Moribundo Chat
And how would that other option?
– Moribundo Chat
@Moribundochat With the question closed can not answer.
– Caffé
ta open now.
– Moribundo Chat
@Moribundochat It’s not about you marking an answer as accepted or not :D I would answer even if you already accepted one. The problem is that your question was closed by the site moderator. Perhaps if you make an edit it can be reopened. Try to edit the question and mention the name of the columns ("name, color, type...") or whatever... I don’t know what the moderator didn’t understand.
– Caffé
Speak for me mp, here is private msg? not even seen kkkkk If there is another way, I want to learn too. It is always good to learn several ways to solve the same problem.
– Moribundo Chat
@Moribundochat, I would use a completely different shape. I would create a class with the attributes you need. Then just create a List of this class and add the options you need. Dai to recover the specific positions have several forms, but I would use lambda expressions. With the question closed we can not present the example. Good luck.
– Thiago Henrique