클래스와 인터페이스로부터 다중 상속받을 때는 항상 클래스가 선언문의 제일 앞에 와야 한다.
c.f. foreach
class Time
{
private class Int60 {
private int Integer;
public Int60(int avalue) { Value = avalue; }
public int Value {
get { return Integer; }
set { if (value >= 0 && value < 60) Integer = value; }
}
}
private int hour;
private Int60 min, sec;
public Time(int aHour, int aMin, int aSec) {
hour = aHour;
min = new Int60(aMin);
sec = new Int60(aSec);
}
public void OutTime() {
Console.WriteLine("{0}시 {1}분 {2}초", hour, min.Value, sec.Value);
}
}
using System;
using System.Collections;
class HanBridge
{
static string[] Bridge = {"팔당", "강동", ..};
public IEnumerator GetEnumerator() {
for (int i = 0; i < Bridge.Length; i++) { yield return Bridge[i]; }
}
}
class CSTest
{
static void Main() {
HanBridge hb = new HanBridge();
foreach (string b in hb) { .. }
}
}
class BaseClass
{
public int a, b;
public BaseClass() {
a = 1;
b = 1;
}
public BaseClass(int a, int b) {
this.a = a;
this.b = b;
}
public virtual void Intro() {
..
}
}
class DerivedClass : BaseClass
{
public int c;
public DerivedClass() {
c = 1;
}
public DerivedClass(int a, int b, int c) : base(a, b) {
this.c = c;
}
public override void Intro() {
base.Intro();
Console.WriteLine("학번:" + StNum);
}
}