IEnumerator does not implement interface IEnumerable

Scott Neustadt

I am unsure why I am getting the following error message:

Error CS0540 'Tilemap.IEnumerable.GetEnumerator()': containing type does not implement interface 'IEnumerable' enter image description here

Here is my code:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TileMapper
{
    class Tilemap<T>
    {

        //Tilemap implementation
        private readonly T[,] tilemap;

        public int Width { get; }
        public int Height { get; }

        public Tilemap(int width, int height)
        {
            this.Width = width;
            this.Height = height;
            this.tilemap = new T[width, height];
        }

        public T this[int x, int y]
        {
            get { return this.tilemap[x, y]; }
            set { this.tilemap[x, y] = value; }
        }

        //Tilemap as collection
        public int Count => this.Width * this.Height;

        public IEnumerator<T> GetEnumerator()
        {
            for (int y = 0; y < this.Height; y++)
            {
                for (int x = 0; x < this.Width; x++)
                {
                    yield return this[x, y];
                }
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

    }
}

I've searched for similar errors but most just reference adding the

 IEnumerator IEnumerable.GetEnumerator()
            {
                return this.GetEnumerator();
            }

which is what is giving me the error.

InBetween

Your class definition doesn't say it implements IEnumerable<T>:

class Tilemap<T>: IEnumerable<T>
{
     //...
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

When using "yield" why does compiler-generated type implement both IEnumerable and IEnumerator

From Dev

How does int map to IEnumerator<int> when implementing IEnumerator interface?

From Dev

Implement interface's IEnumerable<BaseClass> with IEnumerable<DerivedClass>?

From Dev

Implementing IEnumerator/ IEnumerable with IDispose error

From Dev

What is the reason implementing IEnumerable and IEnumerator

From Dev

IEnumerator IEnumerable vb to C#

From Dev

How does Visual Studio evaluate the IEnumerable without breaking into its IEnumerator<T>'s MoveNext?

From Dev

How does Visual Studio evaluate the IEnumerable without breaking into its IEnumerator<T>'s MoveNext?

From Dev

C# Npgsql connection error: Npgsql.NpgsqlConnection doesn't implement interface System.Collections.IEnumerator

From Dev

Does not implement interface member issues

From Dev

Error: Does not implement interface member

From Dev

Error: Does not implement interface member

From Dev

Class does not implement interface member

From Dev

Does not implement interface member MVC

From Dev

implement ienumerable with ienumerable<T>

From Dev

Why is IEnumerable<T> necessary when there is IEnumerator<T>?

From Dev

Why doesn't the following work? (IEnumerable/ IEnumerator)

From Dev

IEnumerable<T> and IEnumerator - some clarification please

From Dev

IEnumerable<T> and IEnumerator - some clarification please

From Dev

cannot initialize type with a collection initializer because it does not implement ienumerable

From Java

'append' called on an object that does not implement interface FormData

From Dev

Why does ArrayList implement RandomAccess Interface?

From Dev

How does Java implement interface polymorphism?

From Dev

'stepUp' called on an object that does not implement interface HTMLInputElement

From Dev

Visitor Pattern "does not implement interface" error

From Dev

Why does the ExecutorService interface not implement AutoCloseable?

From Dev

why ZonedDateTime class does not implement TemporalAdjuster interface

From Dev

Error 1: does not implement interface member

From Dev

Fighter class does not implement interface member

Related Related

  1. 1

    When using "yield" why does compiler-generated type implement both IEnumerable and IEnumerator

  2. 2

    How does int map to IEnumerator<int> when implementing IEnumerator interface?

  3. 3

    Implement interface's IEnumerable<BaseClass> with IEnumerable<DerivedClass>?

  4. 4

    Implementing IEnumerator/ IEnumerable with IDispose error

  5. 5

    What is the reason implementing IEnumerable and IEnumerator

  6. 6

    IEnumerator IEnumerable vb to C#

  7. 7

    How does Visual Studio evaluate the IEnumerable without breaking into its IEnumerator<T>'s MoveNext?

  8. 8

    How does Visual Studio evaluate the IEnumerable without breaking into its IEnumerator<T>'s MoveNext?

  9. 9

    C# Npgsql connection error: Npgsql.NpgsqlConnection doesn't implement interface System.Collections.IEnumerator

  10. 10

    Does not implement interface member issues

  11. 11

    Error: Does not implement interface member

  12. 12

    Error: Does not implement interface member

  13. 13

    Class does not implement interface member

  14. 14

    Does not implement interface member MVC

  15. 15

    implement ienumerable with ienumerable<T>

  16. 16

    Why is IEnumerable<T> necessary when there is IEnumerator<T>?

  17. 17

    Why doesn't the following work? (IEnumerable/ IEnumerator)

  18. 18

    IEnumerable<T> and IEnumerator - some clarification please

  19. 19

    IEnumerable<T> and IEnumerator - some clarification please

  20. 20

    cannot initialize type with a collection initializer because it does not implement ienumerable

  21. 21

    'append' called on an object that does not implement interface FormData

  22. 22

    Why does ArrayList implement RandomAccess Interface?

  23. 23

    How does Java implement interface polymorphism?

  24. 24

    'stepUp' called on an object that does not implement interface HTMLInputElement

  25. 25

    Visitor Pattern "does not implement interface" error

  26. 26

    Why does the ExecutorService interface not implement AutoCloseable?

  27. 27

    why ZonedDateTime class does not implement TemporalAdjuster interface

  28. 28

    Error 1: does not implement interface member

  29. 29

    Fighter class does not implement interface member

HotTag

Archive