Do I have to have 2 different Main methods, 1 without any arguments and 1 with string[] args but private and static?
Do I have to have 2 different Main methods, 1 without any arguments and
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No – you only have to have one
Mainmethod. Indeed, if you have more than one staticMainmethod in a class, I don’t believe you can specify that class as an entry point.It does have to be static though; the class can’t be generic and neither can the method. It can be:
intstring[]It has to be static and non-generic as otherwise the CLR would have to create an instance of the class or work out what type parameter you wanted, respectively. It doesn’t have enough information to make either of those decisions – but it doesn’t need any information for a static non-generic method in a non-generic class.