❔ Basic question on linear search in list
Hello, I am making a blog/notebook for an assignment and I have a list which contains vectors with 3 elements, title/date/body - i need to do a linear search for a title but I cant find any information on how to loop through the first element on all the vectors in the list, any ideas?
Also, i have a DateTime-variable that is declared in the switch function, do i need to declare this at the top before using in Case 1?`
Help much appreciated : - P
6 Replies
Should be as simple as that
Or, if LINQ is permitted, you can do
Though seeing how you use an array instead of a class to represent a book, whatever course you're taking didn't even touch on classes yet
So LINQ being permitted or talked about is unlikely
We have touched on classes but i was specifically told not to use it for this assignment and to include a basic linear search for a title : - )
hmm soo.. i dont really understand, can you advice me what is wrong here on why this doesnt work?
blogPostList[i]
is an array
You can't compare an array to a string
The array of a book, far as I can tell, has the title on the 0
th index
So you should do searchWord == blogPostList[i][0]
aaaaaaaaah! so [i][0] vill check index 0 of all objects in array?
that was the missing piece, thank you! 😄
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.