Hey,
Im having a problem with the below code:
Code:
AddressBook addr = new AddressBook();
do
{
menu_choice = addr.DisplayMenu();
....
} while (cont_menu != false);
In that code menu_choice (int) is always the same value as is set in the first time of the loop, as if the DisplayMenu() method is never called after the 1st iteration.
However if i place AddressBook addr = new AddressBook(); inside the loop it works and displays the menu and sets the correct value of menu_choice.
This to me didnt seem the correct way of doing it though, Becase surly creating a new object/instance to a class for every iteration of the loop is inefficent?
Please can someone explain how this should be done.
Thanks