So I have this code in Game.cs
:
public string _type { get; }
public int _strength;
public Game(string charType, int strength) {
this._type = charType;
this._strength = strength;
}
public override string ToString() {
return $"{_type} {_strength}";
}
And I have this code in Program.cs
:
List<Game> JoinLists = new List<Game>();
JoinLists.Add(new Game("Elf", 6));
JoinLists.Add(new Game("Angel", 10));
JoinLists.Add(new Game("Demon", 10));
JoinLists.Add(new Game("Wizard", 9));
JoinLists.Add(new Game("Undead", 7));
JoinLists.Add(new Game("Vampire", 9));
JoinLists.Add(new Game("Troll", 6));
Console.WriteLine("This is the last of characters that are owned by you: ");
List<Character> chars = BusinessLayer.Instance.GetAllCharacters();
foreach(var character in JoinLists)
{
Console.WriteLine(character.charType);
foreach (Character c in chars)
{
Console.WriteLine(c.Health);
}
}
I just want to print the charType
. Any way I can do that please?
I get this error:
'Game' does not contain a definition for and no accessible extension method accepting a first argument of type 'Game' could be found (are you missing a using directive or an assembly reference?)