C#: Adding extension methods to a base class so that they appear in derived classes

前端 未结 5 873
旧时难觅i
旧时难觅i 2021-01-04 10:02

I currently have an extension method on System.Windows.Forms.Control like this:

public static void ExampleMethod(this Control ctrl){ /* ... */ }
5条回答
  •  猫巷女王i
    2021-01-04 10:35

    You can also make sure your extensions aren't defined in a namespace, then any project that references them will auto-import them.

提交回复
热议问题