Link to home
Start Free TrialLog in
Avatar of lakshmankoneru
lakshmankoneru

asked on

static variables

Can anyone explain this........................................

Static variables declared within nonshared methods are per instance: each instance of the type that contains the method has its own copy of the static variable.

I need to create static variables per instance..... in my application... is it possible... Please let me know?

thanks,
Lakshman

Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

yeah you are reading the VB.NET help for static ...

out of curiosity isnt a static variable scoped to an instance really an instance variable ?

public class foo {
    private int bar;

    public void test() {
         bar += 1;
    }
}

this would be scoped to the instance no ?
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxorilanguageequivalentskeywords.asp

under Misc. Lifetime (second chart from bottom) no C# equivalent ... mostly for the reasons shown.