I have a generic class, Class<T>, that implements IEnumerable<T>. T is also constrained to implement IConvertable.
I also want this class to be able to pretend to be a string-like object, so I want to implement IEnumerable<char>. However, IEnumerable<T> and IEnumerable<char> collide -- what happens if T is char?
Does anyone have any suggestions on how to accomplish this?
EDIT: Here's some clarification -- I'd like to be able to do the following:
public IEnumerator<T> GetEnumerator()
{
for (var i = _offset; i < _offset + _length; i++)
yield return _array[i];
}
public IEnumerator<char> GetEnumerator()
{
for (var i = _offset; i < _offset + _length; i++)
yield return _array[i].ToChar(null);
}