求指导:非泛型 类型“System.Collections.IEnumerator”不能与类型实参一起使用
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace TestIterator1
{
public class Tokens :
IEnumerable
{
private string elements;
Tokens(string source,char delimiters )
{
elements = source.Split(delimiters);
}
public
IEnumerator<char> GetEnumerator()
{
return new TokenEnumerator(this);
}
private class TokenEnumerator :
IEnumerator
{
private int position = -1;
private Tokens t;
public TokenEnumerator(Tokens t)
{
this.t = t;
}
public bool MoveNext()
{
if (position < t.elements.Length - 1)
{
position++;
return true;
}
else { return false; }
}
public void Reset()
{
position = -1;
}
public object Current
{
get { return t.elements; }
}
}
&nbs