class Turns
{
private int number;
public void Counts(int getTurn, out int getBack)
{
if (getTurn.Equals(1))
{
number++;
}
getBack = number;
}
}
class Turns
{
private int number;
public void Counts(int getTurn, out int getBack)
{
if (getTurn.Equals(1))
{
number++;
}
getBack = number;
}
}
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 26, 2013, 8:23 AM EDT
When number was an instance field, it would start off at 0 for each instance.
However, when you changed it to static, it would start off at 0 for the class as a whole and would be incremented by 1 as each instance called the Count method.
VulpesRank #55 · 29.2K reputationPosted May 26, 2013, 7:55 AM EDT
Felice Massaro15 reputationPosted May 26, 2013, 8:00 AM EDT
I do not understand why for you the original one is working. Thats interesting.
Felice Massaro15 reputationPosted May 26, 2013, 8:25 AM EDT