newbie Main() or variable scope issue

G

Guest

Yes I've searched msdn, this must be so simple. I'm new to programming in general.
I created a solution with a form1 that creates a new form1 in the Main entry point. (Normal)
A user selects a folder and my app counts the files and folders for other parts of the program.
Since these counts are used in other parts of the program I tried this:
public int intFolderCount=0;
after the Class line where the other proerties are declared
on build I get an "object reference is required for..." at any line ii have ntFolderCount on.
Day 1 issue I know...thanks for any help tho
 
B

burke.anthony.j

Yes I've searched msdn, this must be so simple. I'm new to programming in general.
I created a solution with a form1 that creates a new form1 in the Main entry point. (Normal)
A user selects a folder and my app counts the files and folders for other parts of the program.
Since these counts are used in other parts of the program I tried this:
public int intFolderCount=0;
after the Class line where the other proerties are declared
on build I get an "object reference is required for..." at any line ii have ntFolderCount on.
Day 1 issue I know...thanks for any help tho

Make sure that you remember that static methods cannot access instance
data directly.

This code won't work:

public class FooBarTester
{
public int Foo;
public static void Bar()
{
Foo = 1; //this method has no can't see Foo
FooBarTester fbt = new FooBarTester();
fbt.Foo = 1; //this will work because it is referencing an
instance field that belongs to an instance
}
}
 
V

VJ

We need more information to help you. please post a short sample cs file or
project of your problem,

VJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top