C#:与Object一起使用的类

Gun*_*arJ 2 c# dll class object

如何创建与特定对象一起使用的类(在DLL中)?例如,Bitmaps调用的类可以执行某些操作.例如

位图bmp =新位图;
bmp.ThingToDo():

Hom*_*mam 7

看看扩展方法.

您可以将您的方法添加到类Bitmap,如下所示:

public static class CustomExtension
{
     public static void ThingToDo(this Bitmap bitmap)
     {
         // add your functionality here and use bitmap
     }
}
Run Code Online (Sandbox Code Playgroud)

祝好运!