Update for 22-02-22 15:45

This commit is contained in:
Tyler Perkins 2022-02-22 15:45:01 -05:00
parent 33a3280b31
commit 74614184d6

View File

@ -35,3 +35,39 @@ Something that is IEnumerable can be used with an enumerator object. This
allows some object to work with LINQ queries. IEnumerable also requires
`IEnumerator<T>` to be defined. `IEnumerator<T>` also needs
[[#System.IDisposable]] to be implimented.
{{{
public class FooEnumerable : IEnumerable<string>
{
private string _data;
//must impliment
public IEnumerator<string> GetEnumerator()
{
return new FooEnumerator(_data);
}
//must impliment
private IEnumerator GetEnumerator1()
{
return this.GetEnumerator();
}
//now override the IEnumerator one
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator1();
}
}
public class FooEnumerator : IEnumerator<string>
{
//required
public string Current
{
get
{
return "some val";
}
}
}
}}}