I am completely stuck on this assignment. Can anyone help? With the online class I am taking, there is a discussion forum, so I got some help on there but I am unsure as to why the advice given works and how I know when to use the code they provided. My actual questions are within the code below. I would appreciate any assistance/clarification. Thank you!!
For the reason you need the temporary value: the code you posted doesn't indicate why you need one. I am guessing there is more to this problem then you have told us so far. What was the original problem that the other forum told you to use a temp variable to solve? Does the GeoRows iterator re-use the instance of GeoRow it returns (i.e. when you put oneRow into the list you get a list filled with the last row over and over again?
edit-- I'm too slow
It's a fairly long problem. We are reading in data from a file, copying the data to a list, promting the user for a search term(name), searching the file to see if the search term (name given) matches a name in the name column of one of the rows in the list. If so, we need to add the row to a new list, searchResults and then print the list to a file.
Natasha Reaney wrote:The variable is considered a reference variable, correct? So when I initialize it with the code below, I am creating a new object/instantiating a class? When I am using reference variables do I always initialize them to new?
You either need to create a new one (like you do in the example you posted) or you need to assign the variable a reference to one that has already been made.
None of that really explains why you need the temporary variable though, or why you feel you need to fill it with the data from oneRow before you put oneRow into the results list.