I am trying to practice OOP. I have a class called Cinema and interface called location. Location Interface has List type and when I am trying to add the location name, It is giving error. Any direction or suggestion will be great -
The error is: "The name 'cinema_location' does not exist in the current context."
namespace MOSS.Interfaces
{
interface loc
{
List<string> location { get; set;}
}
}
namespace MOSS
{
class Cinema : Interfaces.loc
{
List<string> cinema_location = new List<string>();
cinema_location.Add("location1");
cinema_location.Add("location2");
public List<string> location
{
get
{
return cinema_location;
}
set
{
cinema_location = value;
}
}
public void DisplayCinema()
{
string loc;
string Session;
for(int i = 0; i < cinema_location.Count; i++)
{
loc = cinema_location[i];
Console.WriteLine("Cinema Location: {0}", loc);
}
}
}
}
cinema_location.Add("location1");can't just be in the body of a class.