Remove or overwrite single element of list of arrays
(not completely sure its called list of arrays)
Basically i have one of these:
List<string[]> blogPostList = new();
each post in the list has three elements like this:
string[] blogPost = new string[3];
If you look at the picture, I am trying to let the user "overwrite" the title, by first removing it with removeAt (and then just add new with blogPostList.Add(blogPost[index][0]);) but I cant find anywhere how to write the code for the removeAt? since i want to overwrite just index 0, and not all 3 index of the blogPost
6 Replies
there's nothing to remove
just overwrite it
but you kinda need to specify which blogpost to edit
the index should be the specified blogpost, and then element 0 of the specified blogpost
is there a method to ooverwrite directly or do i just do blogPostList.Add(blogPost[index][0]);?
so
blogPostList[index][0] = Console.ReadLine();
?haha.. so it was as simple as that :p
also, one more question!
When I show the list top to bottom, i first want to sort it by date that is saved in index 2 on all blog posts, what type of function can be used? I dont know what to google
OrderBy
thanks! 😄