代码如下:
public class Enumerator : IEnumerator, IDisposable //这是什么?为什会有两个接口?允许多个接口
{ //被一个类继承么?
private int state;
private object current; public Enumerator(int state)
{
this.state = state;
} public bool MoveNext()
{
switch (state)
{
case 0:
current = "Hello";
state = 1;
return true;
case 1:
current = "World";
state = 2;
return true;
case 2:
break;
}
return false;
} public void Reset()
{
throw new NotSupportedException();
} public object Current
{
get { return current; }
} public void Dispose()
{
}
}C#继承
public class Enumerator : IEnumerator, IDisposable //这是什么?为什会有两个接口?允许多个接口
{ //被一个类继承么?
private int state;
private object current; public Enumerator(int state)
{
this.state = state;
} public bool MoveNext()
{
switch (state)
{
case 0:
current = "Hello";
state = 1;
return true;
case 1:
current = "World";
state = 2;
return true;
case 2:
break;
}
return false;
} public void Reset()
{
throw new NotSupportedException();
} public object Current
{
get { return current; }
} public void Dispose()
{
}
}C#继承
那么接口中所有定义的方法都要被继承的非抽象类来实现么?
那么接口中所有定义的方法都要被继承的非抽象类来实现么?那是自然的。