From: Gordon Padwick on
Thanks, Igor. Now it begins to make sense.

Gordon
"Igor Tandetnik" <itandetnik(a)mvps.org> wrote in message
news:%23gGvVrqhKHA.2132(a)TK2MSFTNGP05.phx.gbl...
Gordon Padwick wrote:
> public class PeopleEnum : IEnumerator
> {
> .. .
> public bool MoveNext()
> {
> position++;
> return (position < _People.Length);
> }
> . . .
> }
>
> My understanding is that the PeopleEnum class is derived from the
> IEnumerator class

To be precise, PeopleEnum implements IEnumerator interface.

> of which the members include the MoveNext method with a
> return type of bool.
>
> So, in the class PeopleEnum class definition, why is it necessary to again
> define the MoveNext method?

An interface declares some methods. A class that wants to implement the
interface needs to implement all its methods.

If you are familiar with C++, a C# interface is similar to a C++ class with
no data members, and all methods being pure virtual. If you are familiar
with COM, a C# interface is similar to a COM interface.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily
a good idea. It is hard to be sure where they are going to land, and it
could be dangerous sitting under them as they fly overhead. -- RFC 1925

First  |  Prev  | 
Pages: 1 2
Prev: C++ and VC++ Differences
Next: std::map question