C# Error
CS1623 – Iterators cannot have ref, in or out parameters
Reason for the Error & Solution
Iterators cannot have in ref or out parameters
This error occurs if an iterator method takes an in, ref, or out parameter. To avoid this error, remove the in, ref, or out keyword from the method signature.
Example
The following sample generates CS1623:
// CS1623.cs
using System.Collections;
class C : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield return 0;
}
// To resolve the error, remove in
public IEnumerator GetEnumerator(in short i) // CS1623
{
yield return i;
}
// To resolve the error, remove ref
public IEnumerator GetEnumerator(ref int i) // CS1623
{
yield return i;
}
// To resolve the error, remove out
public IEnumerator GetEnumerator(out float f) // CS1623
{
f = 0.0F;
yield return f;
}
}