Partial Class vs Extension Method

前端 未结 9 1672
無奈伤痛
無奈伤痛 2021-02-01 02:09

I dont have much experience of using these 2 ways to extend a class or create extension methods against a class. By looking others work, I have a question here.

I saw pe

9条回答
  •  醉梦人生
    2021-02-01 02:11

    A partial class is useful when you want to extend a generated class. This way you can write your code in one file, and then when/if the other 'part' of your class needs to be re-generated, it can be done safely, as that code file hasn't changed.

提交回复
热议问题