Hey guys,
I added a class to my project and called it MyCustomClass, now in my main class I initialize it by saying
MyCustomClass test = new MyCustomClass;
What I am trying to do is when I create this class I want it to automatically run a default method that will do bunch of stuff.
with java I had a Main method that will happen whenever a class is created, I am trying to figure out what this method is with C# and how do I create it. So if you are familiar with java I am looking for public static void main(String [], args) method.
Yeah its a really dumb question, I just couldn't find the answer on google...
Thanks for the help.
Loading
VulpesPosted Oct 20, 2012, 7:10 PM
If you want a method to run automatically when you create an object of your class, then you need to call it from the constructor. For example:
bagzliPosted Oct 27, 2012, 6:43 PM
Cheers,
Bagzli
VulpesPosted Oct 21, 2012, 12:53 PM
Console.ReadKey() simply waits for the user to press a key. If (as most folks do) you're running a console application in debug mode using Visual Studio, then you'll find that the console window will close before you've had time to read the output. Adding Console.ReadKey() at the end of the program is one way to prevent this from happening.
bagzliPosted Oct 21, 2012, 12:20 PM