Partial Classes in C#

后端 未结 20 3061
时光说笑
时光说笑 2021-02-19 07:59

Are there are good uses of Partial Classes outside the webforms/winforms generated code scenarios? Or is this feature basically to support that?

相关标签:
20条回答
  • 2021-02-19 09:03

    LINQ to SQL makes good use of partial classes to extend designer generated code. I think you will typically find this pattern of partial classes being used by designer-created code.

    0 讨论(0)
  • 2021-02-19 09:04

    Anywhere you'd have used #region sections before probably makes more sense as separate files in partial classes.

    I personally use partial classes for large classes where static members go in one file and instance members go in the other one.

    0 讨论(0)
提交回复
热议问题