I am learning C # and I am very new to this, so forgive me for the seemingly stupid question. I have some experience with Java, and I noticed that C # programs also need the main() method in their main class.
What if I want to create a class that is not a main class, i.e. the one I import into the main class?
I tried to do this, and when I compile (using cmd with csc File.cs ), the compiler says that the .exe file it will make does not have a main() method. Does this mean that I was wrong and that every class needs the main() method, or that I am compiling it incorrectly?
Maybe the problem is in the code (as I rely on my knowledge of Java syntax), which looks like this:
public class Class { int stuff; public Class(int stuff) { this.stuff = stuff; stuff(); } public void method() { stuff(); } }
EDIT: I'm afraid this is terribly misunderstood. I do not ask if the file needs the main method, I ask how I can import this class into another class, because I understand that if I do this, I will not have the main thing (as I said, I have some Java experience ), but whenever I try to compile without it, the compiler tells me that I need it.
c # main class
Bluefire
source share