Same name class in C#
Can be create two class of same name in a assembly, if yes, then how can it do.
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
Shen Hengbin94 reputationPosted Jul 4, 2012, 7:00 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 4, 2012, 7:24 PM EDT
Same Class name with in a project is possible if and only if both are in different namespace or different assembly.
Actually Why you required same class name in assembly?
Yes Shen is right if you both classes are partial then it combine at compile time.
hope this will help.
Mahesh ChandRank #1 · 393.3K reputationPosted Jul 4, 2012, 9:43 PM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 5, 2012, 1:10 AM EDT
The C# compiler combines the members of the two partial classes which are therefore treated just the same as if they had been declared as a single class: