在类中声明使用了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();
}
}