[Mono-list] Real noob question!
Wed, 20 Oct 2004 14:03:34 +1000
you code would work ok.
It is funny to start with, but the main method is static, so it isn't
called as a method on a class instance.
The main method is often very procedural in nature and often has some
sort of control loop (in a GUI this is hidden in what is called the
I often just make a class with only a main method in it just to
separate out the program entry point.
On 20/10/2004, at 1:36 PM, Eric Damron wrote:
> Okay, I've been doing everything wrong. I've been trying to put some
> of my program logic into the main method of one of my classes and have
> been fighting it all the way!
> What is the correct way to structure the class that kicks off the
> whole thing? Are you really suppose to create an instance of the
> class within the class itself??
> public class foo
> int somevariables;
> AnotherClass anotherClass = new AnotherClass();
> public foo()
> // this is a constructor
> private foo2()
> // this is a method of class foo
> static void main()
> // here is where I get into trouble
> foo f = new foo(); // Instanating a class within itself is too
> Since everything seems to have to be inside a class, the code that
> must first execute must also be in a class but how can it execute
> unless there is an instance of the class? How can there be an
> instance of the class if no code can execute??? It's the chicken or
> the egg problem!
> Mono-list maillist - Monofirstname.lastname@example.org