求一段能编译通过的int类型的拓展方法
例如调用的时候 int i = 1234;
Console.WriteLine(i.ReverseDigits());
ReverseDigits()为int的拓展函数
求一段代码借鉴借鉴,学习一下,谢谢
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleTest { static class intExtendMethod { public static void showmsg(this int i) { Console.WriteLine("int show extend message!"); } public static int ReverseDigits(this int i) { /*************/ /*degisn here*/ /*************/ return --i; //return your result } public static int addOne(this int i,int n) { return i + n; } } class Program { static void Main(string[] args) { Program test = new Program(); int i = 0; test.testExtend(i, 1); i = 12345; test.testExtend(i, 10); i = -12345; test.testExtend(i, -10); Console.ReadKey(); } private void testExtend(int m,int n) { m.showmsg(); Console.WriteLine("{0}", m.ReverseDigits()); Console.WriteLine("{0}", m.addOne(n)); } } }