标签:c style class blog code java
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace 静态类密闭类 7 { 8 class Program 9 { 10 static void Main(string[] args) 11 { 12 //A a = new A();//错误,静态类不能new 13 14 //Math m = new Math();//错误,静态类不能new 15 Math.PI;//静态类直接使用,以后的SqlHelper,Console也是一样 16 17 //string s = ""; 18 //面试题:不能创建一个从String类继承的类,因为String是sealed 19 } 20 } 21 22 static class A 23 { 24 //静态类中不能声明非静态成员,木有意义! 25 //static类里面全是static方法 26 //private int Age; 27 public static int PI; 28 } 29 30 //密闭类可以有父类,联系太监 31 sealed class B//sealed密闭类不能"被"继承,主要基于安全考虑 32 { 33 } 34 35 //class C : B//错误,密闭类不能被继承,太监不有后代 36 //{ 37 //} 38 }
静态类2014年6月9日10:02:28,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/skyl/p/3777306.html