c#sealed的使用

来源:互联网 发布:火焰恶作剧软件 编辑:程序博客网 时间:2024/06/06 23:52

在类中声明使用了sealed修饰符的类称为密封类。密封类的结构式隐式密封的,不能被继承

举例使用密封类

using System;using System.Collections.Generic;using System.Linq;using System.Text;public enum sex { women, man};sealed class sealedc   //声明为密封类{    public int x;    public int y;}class Mainclass{    public static void Main()    {        sealedc s = new sealedc() ;        s.x = 100;        s.y = 200;        Console.WriteLine("x={0}, y = {1}", s.x, s.y);        Console.ReadLine();    }}

 

原创粉丝点击