Which is better: many class definitions in the same file or every class definition in a separate file?

Posted by Javed Akram on Programmers See other posts from Programmers or by Javed Akram
Published on 2011-03-11T18:01:10Z Indexed on 2011/03/12 0:17 UTC
Read the original article Hit count: 253

Filed under:
|

Which is better: many class definitions in same file or every class definition in separate file?

Examples:

1) Many classes in same file. Say, myManyClasses.cs:

namespace myPack
{
   class myClass1()
   {
   }
   class myClass2()
   {
   }
   class myClass3()
   {
   }
  . 
  . 
  .
}

2) Every class in separate file:

myClass1.cs

namespace myPack
{
   class myClass1()
   {
   }
}

myClass2.cs

 namespace myPack
 {
   class myClass2()
   {
   } 
 }

. . .

© Programmers or respective owner

Related posts about c#

Related posts about .NET