码迷,mamicode.com
首页 > 其他好文 > 详细

静态类2014年6月9日10:02:28

时间:2014-06-09 18:17:44      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   java   

bubuko.com,布布扣
 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 }
bubuko.com,布布扣

 

静态类2014年6月9日10:02:28,布布扣,bubuko.com

静态类2014年6月9日10:02:28

标签:c   style   class   blog   code   java   

原文地址:http://www.cnblogs.com/skyl/p/3777306.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!