C#扩展一个现有的类
做个记录,写个示例
using System; class Rubbish { public void Say() { Console.Write("Hello"); } } static class RubbishExtensions { public static void Say(this Rubbish argRubbish, string argString) { Console.Write(argString); } } class Program { static void Main(string[] args) { Rubbish theRubbish = new Rubbish(); theRubbish.Say("Hey"); Console.ReadKey(false); } }