Why can?t i create a list of Sodas in this project? please help me im really new to this :S the error message i get is "Error CS0246 The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)" on the line i made BEEFCAKE and i get it two times. one for each use of the word "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);
}
}
}
Last edited by a moderator: