CSharp3 面向对象.ppt

CSharp3 面向对象.ppt

接口与继承 常用接口 ICollection IList IComparable IEnumerable IEnumerator IDictionary uint x = 99; bool b1 = MyMath.IsPrime(x); 扩展 类的重用 定义派生类: 继承 扩展已有类: 扩展方法 public static class MyMath { public static bool IsPrime(uint n) { for (uint i = 2; i = n / 2; i++) if (n % i == 0) return false; return true; } } 扩展方法 扩展方法的定义 静态类的静态方法 uint x = 99; bool b1 = MyMath.IsPrime(x); public static class MyMath { public static bool IsPrime(this uint n) { for (uint i = 2; i = n / 2; i++) if (n % i == 0) return false; return true; } } 扩展 扩展方法的定义 静态类的静态方法 this关键字

文档评论(0)

1亿VIP精品文档

相关文档