user10489212
user10489212

Reputation:

How to solve this error: No best type found for implicitly-typed array

Why am I not able to use the boolean parameter in this statement? It's showing me this error:

No best type found for implicitly-typed array

   public IEnumerator GetEnumerator()
        {
            yield return new[] { "ABC123", "9999", "9999", "1000", "20180427120717123", false };
}

My code

Upvotes: 2

Views: 1295

Answers (2)

Dmitrii Bychenko
Dmitrii Bychenko

Reputation: 186833

It seems, that you want to enumerate object[]s:

public IEnumerator<object[]> GetEnumerator() {
  yield return new object[] { "ABC123", "9999", "9999", "1000", "20180427120717123", false };
  yield return new object[] { "ABC123", "9999", "9999", "1000", "20180427120717123", true };
}

Upvotes: 1

Marc Gravell
Marc Gravell

Reputation: 1064184

If you want a mixed array: just don't be vague:

yield return new object[] { "ABC123", ..., false }

The difference is the new object[] {...} instead of new [] {...}, which means that the compiler doesn't need to try to figure out what you meant.

Upvotes: 5

Related Questions