Is it a bad practice to have multiple classes in the same file?

后端 未结 15 2262
眼角桃花
眼角桃花 2020-12-08 03:48

I used to have one class for one file. For example car.cs has the class car. But as I program more classes, I would like to add them to the same file. For

15条回答
  •  醉酒成梦
    2020-12-08 04:17

    As a rule of thumb, one class/one file is the way to go. I often keep several interface definitions in one file, though. Several classes in one file? Only if they are very closely related somehow, and very small (< 5 methods and members)

提交回复
热议问题