newbie Main() or variable scope issue

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
}
}
 
We need more information to help you. please post a short sample cs file or
project of your problem,

VJ
 
Back
Top