HI,
I have a requirement to create a C# application with some methods in it and without any main. Can this be possible? Can we use any other entry points than main()?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Khan Abrar AhmedRank #778 · 3K reputationPosted Apr 7, 2014, 12:13 AM EDT
You can't, because main() method is the entry point of consol application, form that method progams are executing.
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 7, 2014, 12:32 AM EDT
hi,
The Main method is the entry point of a C# console application or windows application. I think it is not possible to C# application without main method. but we may have multiple main methods in different class.
Abhay ShankerRank #375 · 6.7K reputationPosted Apr 7, 2014, 12:40 AM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 7, 2014, 12:49 AM EDT
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Apr 7, 2014, 1:21 AM EDT
VulpesRank #55 · 29.2K reputationPosted Apr 7, 2014, 1:31 AM EDT
However, this is in fact an illusion. When the application is built, VS generates the Main method automatically even though you don't see it.
What you might be thinking of here is a class library application or .NET dll. These don't require an entry-point and don't therefore have a Main method. The purpose of this type of application is to provide library classes for other applications to use.
Where an application does require an entry-point (i.e. an exe), then this has to be provided via a Main() method. Other methods cannot be used instead.