Can we write a c# program without a Class or Structure?
Can we write a c# program without a Class or Structure? If possible can anyone give an example?
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
Abhimanyu K VatsaRank #14 · 51.7K reputationPosted Jun 16, 2011, 4:33 AM EDT
i) C# is fully OOP oriented and it must need at-least a parent class or struct
ii) C# is purely developed to support encapsulation and if you avoid classes then it will not execute
Let's wait for more reply here.
VulpesRank #55 · 29.2K reputationPosted Jun 16, 2011, 4:34 AM EDT
You need at least one class or struct to contain your Main() method as C# doesn't support global functions.
Guest UserRank #1,422 · 1.2K reputationPosted Jun 16, 2011, 4:52 AM EDT
Mahesh ChandRank #1 · 393.3K reputationPosted Jun 16, 2011, 5:51 AM EDT
As everybody else said, there must be at least one class that MUST have the Main method, that is the starting point of a C# application and that is what C# compiler looks for when compile the code.
VulpesRank #55 · 29.2K reputationPosted Jun 16, 2011, 6:06 AM EDT