What is the use of a partial class?

前端 未结 10 1014
梦谈多话
梦谈多话 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:17

    A partial class is used when you want to define a class over one or more files.

    Usually this is used to separate the code that generates the UI from the code that does contains the UI's logic. C# does this for example.

    Sometimes when I have a huge class that cannot be broken down in other ways I used partial classes to separate groups of methods together although I do this very very rarely.

提交回复
热议问题