很简单得出的输出结果:这是一个密封的方法
<span style="font-size:18px;">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace qq
{
sealed class Person
{
public void print_Person_name()
{
Console.WriteLine("张三");
}
}
class Student : Person//密封类不能被继承
{
}
class Program
{
static void Main(string[] args)
{
Student s1 = new Student();
s1.Print_Person_name();//不能调用密封类的方法
Console.ReadLine();
}
}
}</span>
这是一个错误的实例,在我们使用密封类的时候不能出现这样的情况,再者就是这样的关键字我们一般要少用。
以上就是关于C#的密封类的全部内容介绍,希望对大家的学习有所帮助。
注:相关教程知识阅读请移步到c#教程频道。










