C # file size limit

I have a site built using ASP.NET (.NET 2.0). I have many classes in my business logic, and I store them all in one file (BL.cs).

Now I hit the scene where I have 11,000 lines of code in this file. This is a problem - should it be divided into several files, each class in a different file? Is there a restriction that the cs file should not exceed?

+5
source share
5 answers

I adhere to the following rule: 1 file per class (if only for nested classes). 11,000 lines of code in one file look monstrous.

+7
source

, , , 11 000 .

, VS , , - .

- . .

+6

.

+2

, , EF 30k +, . .

+1

.

You will almost never need to have more than a few hundred lines of code per class written by hand, and you should always strive to use one class for each file (and name files with the same name as your class). This is an overall good form for project management, especially a large one.

If this is one huge, automatically generated class, you can consider splitting it into multiple files using the partial keyword .

+1
source

All Articles