Implementing multiple IEnumerables in C# -
i have generic class, class<t>
, implements ienumerable<t>
. t
constrained implement iconvertable
.
i want class able pretend string-like object, want implement ienumerable<char>
. however, ienumerable<t>
, ienumerable<char>
collide -- happens if t
char
?
does have suggestions on how accomplish this?
edit: here's clarification -- i'd able following:
public ienumerator<t> getenumerator() { (var = _offset; < _offset + _length; i++) yield return _array[i]; } public ienumerator<char> getenumerator() { (var = _offset; < _offset + _length; i++) yield return _array[i].tochar(null); }
you need class "pretend string-like object". can make string-like behaviour more explicit , avoid implementing ienumerable<char>
@ all?
public ienumerator<t> getenumerator() { (var = _offset; < _offset + _length; i++) yield return _array[i]; } // either public ienumerator<char> getcharenumerator() { (var = _offset; < _offset + _length; i++) yield return _array[i].tochar(null); } // or public ienumerable<char> ascharsequence() { (var = _offset; < _offset + _length; i++) yield return _array[i].tochar(null); }
Comments
Post a Comment