Code below causes error in class definition line
.....Isolator<T >' does not implement interface member
'System.Collect ions.IEnumerabl e.GetEnumerator ()'.
'Myapp.Isolator <T>.GetEnumerat or()' cannot implement
'System.Collect ions.IEnumerabl e.GetEnumerator ()' because it does not have
the matching return type of 'System.Collect ions.IEnumerato r'.
I tried to change method signature to
public IEnumerator GetEnumerator()
bu this causes another error
....Isolator<T> ' does not implement interface member
'System.Collect ions.Generic.IE numerable<T>.Ge tEnumerator()'.
'Myapp.Isolator <T>.GetEnumerat or()' cannot implement
'System.Collect ions.Generic.IE numerable<T>.Ge tEnumerator()' because it does
not have the matching return type of
'System.Collect ions.Generic.IE numerator<T>'.
How to make this code work ?
Andrus.
using System;
using System.Collecti ons;
using System.Collecti ons.Generic ;
public class Isolator<T: IEnumerable<T>
{
IEnumerable<Tin ner;
public Isolator(IEnume rable<Tenumerab le)
{
inner = enumerable;
}
public IEnumerator<TGe tEnumerator()
{
ArrayList<Tlist = new ArrayList<T>();
foreach (object o in inner)
list.Add(o);
return list.GetEnumera tor();
}
}
.....Isolator<T >' does not implement interface member
'System.Collect ions.IEnumerabl e.GetEnumerator ()'.
'Myapp.Isolator <T>.GetEnumerat or()' cannot implement
'System.Collect ions.IEnumerabl e.GetEnumerator ()' because it does not have
the matching return type of 'System.Collect ions.IEnumerato r'.
I tried to change method signature to
public IEnumerator GetEnumerator()
bu this causes another error
....Isolator<T> ' does not implement interface member
'System.Collect ions.Generic.IE numerable<T>.Ge tEnumerator()'.
'Myapp.Isolator <T>.GetEnumerat or()' cannot implement
'System.Collect ions.Generic.IE numerable<T>.Ge tEnumerator()' because it does
not have the matching return type of
'System.Collect ions.Generic.IE numerator<T>'.
How to make this code work ?
Andrus.
using System;
using System.Collecti ons;
using System.Collecti ons.Generic ;
public class Isolator<T: IEnumerable<T>
{
IEnumerable<Tin ner;
public Isolator(IEnume rable<Tenumerab le)
{
inner = enumerable;
}
public IEnumerator<TGe tEnumerator()
{
ArrayList<Tlist = new ArrayList<T>();
foreach (object o in inner)
list.Add(o);
return list.GetEnumera tor();
}
}
Comment