Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System;
- namespace cap07.usoienumerator
- {
- public class GenteEnumerator : IEnumerator
- {
- public Persona[] personas;
- int position = -1;
- public GenteEnumerator(Persona[] personas)
- {
- this.personas = personas;
- }
- public bool MoveNext()
- {
- ++position;
- return (position < personas.Length);
- }
- public void Reset()
- {
- position = -1;
- }
- object IEnumerator.Current
- {
- get
- {
- return Current;
- }
- }
- public Persona Current
- {
- get
- {
- try
- {
- return personas[position];
- }
- catch (IndexOutOfRangeException)
- {
- throw new InvalidOperationException();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement