가상메서드 - 오버라이드...
# 2) .Net ( Vs 2005 )/WinForm2009. 10. 6. 11:30
가상메서드와 오버라이드 관계를 알아보기 위해 예제로 만들었음.
그닥.. 설명할게 없으므로... 설명은 패쓰~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Virture_Override
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SuperClass s = new _BabyBabyOne(this.textBox1.AppendText);
s.Print();
}
}
public class SuperClass
{
public SuperClass( _Print p)
{
prt = p;
}
public delegate void _Print(string text);
protected _Print prt = null;
public virtual void Print()
{
prt("SuperClass :\t public virtual void Print() " + Environment.NewLine);
}
}
public class _BabyOne : SuperClass
{
public _BabyOne(_Print p )
: base(p)
{
}
public override void Print()
{
base.Print();
prt(" _BabyOne :\t public override void Print() " + Environment.NewLine);
}
}
public class _BabyBabyOne : _BabyOne
{
public _BabyBabyOne(_Print p)
: base(p)
{
}
public override void Print()
{
base.Print();
prt(" _BabyBabyOne :\t public override void Print() " + Environment.NewLine);
}
}
}
그닥.. 설명할게 없으므로... 설명은 패쓰~
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Virture_Override
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SuperClass s = new _BabyBabyOne(this.textBox1.AppendText);
s.Print();
}
}
public class SuperClass
{
public SuperClass( _Print p)
{
prt = p;
}
public delegate void _Print(string text);
protected _Print prt = null;
public virtual void Print()
{
prt("SuperClass :\t public virtual void Print() " + Environment.NewLine);
}
}
public class _BabyOne : SuperClass
{
public _BabyOne(_Print p )
: base(p)
{
}
public override void Print()
{
base.Print();
prt(" _BabyOne :\t public override void Print() " + Environment.NewLine);
}
}
public class _BabyBabyOne : _BabyOne
{
public _BabyBabyOne(_Print p)
: base(p)
{
}
public override void Print()
{
base.Print();
prt(" _BabyBabyOne :\t public override void Print() " + Environment.NewLine);
}
}
}
'# 2) .Net ( Vs 2005 ) > WinForm' 카테고리의 다른 글
디버그윈도우를 만들어서 적용함. (0) | 2009.10.16 |
---|---|
작업트레이위에 스르륵!! 나타나는 폼! (0) | 2009.10.06 |
그리드뷰 각 Row색 바꾸기. (1) | 2009.09.25 |
Win Form이 스윽~~ 나오는 효과내기 (0) | 2009.09.23 |
XmlHelper 를 만들다. (0) | 2009.09.23 |