Groups | Blog | Home
all groups > dotnet compact framework > december 2005 >

dotnet compact framework : public var not visible? :(


Simon Hart
12/31/2005 10:34:13 AM
Are you using VS2003 as I have seen a bug in this version. Try writing to
code to access the variable then compiling forgetting about intellisense for
a minute.

Cheers
Simon.

[quoted text, click to view]

Gilles Kohl [MVP]
12/31/2005 1:49:03 PM
[quoted text, click to view]

Hmm - apologies if this is a mistake you'd never make, but could you
be trying to access an instance variable via the type name of your
form class, instead of via an instance of the form?

That is, if your main forms (class) name is MainForm, and you have a

public int testvar;

in there, you cannot access it from within another form or class via

int v = MainForm.testvar;

For this to work, you'd need to make testvar static, like so:

static public int testvar;

The consequence of this is that this variable is common to all
instances of your form (that is, if you want to open several windows
of this same type) - probably less likely under the CF than under the
full framework.

Regards,
Gilles [MVP].

(Please reply to the group, not via email)
droll
12/31/2005 2:52:00 PM
i must be doing something fundamentally wrong.

i have a main form class in which i declare a
public int testvar;

i have another class i created. this class is in the same namespace as the
main form class. however, i cannot access 'testvar' from this class. it
doesn't show up in intellisense. if i declare an enum in the main form
class, it does show up.

????? what am i doing wrong? :(

droll
1/1/2006 5:07:42 AM
yes, you are right. that's what i'm trying to do. thanks. i understand it
now! *banging head against wall* sigh :(

[quoted text, click to view]

AddThis Social Bookmark Button