There are significant problems here, the first of which seems to be that you have no understanding of variables and their scope - that's not a major problem as it's pretty simple really.
Let's ignore computers for a moment or two and think about friends. Suppose you have a friend called Bob, and he comes round to see you - so you sit him down in the living room, and go to get him a cup of tea. Unfortunately, Bob is deaf, so he can only "hear" you when he is in the same room - because he lip reads. As soon as you are in the kitchen, Bob can't see you, so he can't communicate any information to you - such as the number of sugars he would like. His
scope
is limited to the living room and as soon as you leave it you can't talk to him. So, you go back to the living room to ask him about the sugar, and surprise! It's a different Bob who knows nothing about the tea!
What's happened here is exaggerated, but it is what happens with methods: any variables you declare within the method are only accessible and only exist while the method is being executed. Poor Bob - you killed him when you went to get the tea, and created a new one when you came back for sugar...
If you want Bob to be persistent, then he needs to have a scope which covers the whole house - he needs to get his hearing back. This means declaring the Bob Variable at a class level instead of in a method:
class House
{
MyFriend Bob = new MyFriend();
void LivingRoom()
{
Bob = MyFriend.WantsTea;
}
void Kitchen()
{
if (makingTea)
{
int sugars = Bob.SugarCount;
...
}
}
}
Because Bob is declared outside any method, his scope is the whole of the House class - and any routine in the House class can access him (unless you declare a new variable called Bob inside a method in which case that variable takes precedence).
So, look at your code, and see which scope Bob (AKAK _prices) has in each case!