Jun 21, 2010 08:39 AM|stuie|LINK
I hope someone can confirm my if my understanding on this subject is correct or not.
Ok, firstly a static class only ever exists once and is not an instance. Any static members (ie static int NoOfPeople;) is stored in one place and is shared between all sessions (like the old global variables).
Now static methods is where i'm not 100% sure. If I have a static method that doesn't use any other static members could this cause inconstant results, example (this is a fairly pointless method but just a quick example of the top of my head)
public static class MyQuickMaths
public static int SumThenHalf(int a, int b)
int totalToReturn = a + b;
return totalToReturn / 2;
So in this example if two sessions (or threads) were to call this at the same time - would they both get back the expected results, because the method only uses private data (a, b and totalToReturn).
Im sure this sounds a little simple but I will be using static methods to build user objects and various other objects that there will have to be a 100% garentee that the objects will not get mixed up between sessions and the wrong things return to the user.
Thanks in advance.