当前位置:编程学习 > C#/ASP.NET >>

c#初学问题

以下程序提示:错误 1 使用泛型 类型“System.Collections.Generic.IEnumerable<T>”需要“1”个类型实参
求大神们如何修改?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
    public class Tokens : IEnumerable
    {
        private string elements;
        Tokens(string source, char deliniters)
        {
            elements = source.Split(deliniters);
        }
        public IEnumerator 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;
                }
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Tokens f = new Tokens("This is well-done program.", new char { ' ', '-' });
            foreach (string item in f)
            {
                Console.WriteLine(item);
            }
        }
    }
}
C# --------------------编程问答-------------------- 除
补充:.NET技术 ,  其他语言
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,