What is the use of a partial class?

前端 未结 10 886
梦谈多话
梦谈多话 2021-01-13 00:15

How can a partial class be useful in coding? Can anyone explain in detail with examples?

10条回答
  •  迷失自我
    2021-01-13 01:16

    The main use is to separate designer-generated code (e.g. a UI, or entities) from hand-written code; the two are mashed together at compile time, so you still just get a single class, but you don't see the designer cruft when looking at code.

    It's not the only useful situation, but it's the main one I've come across.

提交回复
热议问题