会员
商店
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Dragon in the sky
whatever happened , go ahead! Happy life of big pig and its dog.
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
公告
虚函数在C#中的用法
Posted on
2008-06-18 15:51
龙泰
阅读(
1531
) 评论(
0
)
编辑
收藏
举报
虚函数是在C#中实现多态的一种方法,你要在子类中对override 关键字修饰要实现的虚方法
父类要使用Vritual关键字。
class
Shape
{
public
virtual
void
Draw()
{
Console.WriteLine(
"
Shape.Draw
"
);
}
}
class
Rectangle : Shape
{
public
override
void
Draw()
{
Console.WriteLine(
"
Rectangle.Draw
"
);
}
}
未完待续......
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2025 龙泰
Powered by .NET 9.0 on Kubernetes