小编TCo*_*Col的帖子

编译错误CS0305

我是C#编程的新手,遇到了一些我无法过去的障碍.

我收到这个编译错误:

CS0305:使用泛型类型'System.Collections.Generic.IEnumerable'需要1个类型参数

用这个代码;

class Program
    {
        static void Main(string[] args)
        {
            Car c = new Car();
            c.PetName = "Frank";
            c.Speed = 55;
            c.colour = "Green";

            Console.WriteLine("Name = : {0}", c.PetName);
            c.DisplayStats();

            Garage carLot = new Garage();

            // Hand over each car in the collection
            foreach (Car c in carLot)
            {
                Console.WriteLine("{0} is going {1} MPH",
                    c.PetName, c.CurrentSpeed);
            }

            Console.ReadLine();
        }

        class Car
        {
            //Automatic Properties
            public string PetName { get; set; }
            public int Speed { get; set; } …
Run Code Online (Sandbox Code Playgroud)

c#

3
推荐指数
1
解决办法
1887
查看次数

标签 统计

c# ×1