无法列出!

阿洛卡

新成员
已加入
2016年5月3日
留言内容
3
编程经验
Beginner
为什么不能在此项目中创建苏打水列表?请帮助我,我真的是新来的:S我得到的错误信息是"错误CS0246类型或名称空间名称'List<>'找不到(您是否缺少using指令或程序集引用?)" on the line i made 蜜蜂蛋糕 我得到了两次。单词的每次使用一个"list"... HELP ME :(


C#:
using System;

namespace sodacrate
{
   
    class Soda
    {
        private string brand;
        private int price;
        private string type;
       
        public Soda(string _brand, int _price, string _type)//Constructor
        {
            brand = _brand;
            price = _price;
            type = _type;
        }
    }  

class Sodacrate
    {

        private Soda[] bottles = new Soda[25]; 
        private int antal_flaskor = 0;
 public void Run()
        {
            Console.WriteLine("V?lkommen till din digitala l?skbacks organiserare!");
            Console.WriteLine("Just nu inneh?ller din back " + (antal_flaskor) + " flaskor");
            Console.WriteLine("F?r att l?gga till en l?sk i backen tryck (1)");
            Console.WriteLine("F?r att se vad som finns i backen tryck (2)");
            Console.WriteLine("F?r att se totalpriset f?r din nuvarande back tryck (3)");
            Console.WriteLine("F?r att avsluta programmet tryck (4)");
            int menyVal = Convert.ToInt32(Console.ReadLine());
            switch (menyVal)
            {
                case 1:
                    add_soda(); // call the methodadd_soda
                    break;
}

//Below is the method i?m trying to execute..


 public void add_soda()
        {
          [COLOR=#ff0000]  [B]List<Soda> avaliableSodas = new List<Soda>();[/B][/COLOR]
            avaliableSodas.Add("Coca-Cola", 10, "l?sk");
            avaliableSodas.Add("Fanta", 10, "l?sk");
            avaliableSodas.Add("Sprite", 10, "l?sk");
            avaliableSodas.Add("P?ronsoda", 10, "l?sk");
            avaliableSodas.Add("Hallonsoda", 10, "l?sk");
            avaliableSodas.Add("Pripps", 15, "l?tt?l");
            Console.WriteLine("Dessa drycker finns i kylsk?pet hos din n?rmaste aff?r!");
}

class Program
        {
            public static void Main(string[] args)
            {
            
                //Skapar ett objekt av klassen Sodacrate som heter sodacrate
                var sodacrate = new Sodacrate();
                sodacrate.Run();
                Console.Write("Press any key to continue . . . ");
                Console.ReadLine();
                Console.ReadKey(true);
            }
        }
    }
 
由主持人最后编辑:
最佳 底部