This should be an easy answer but I’m so n00b.

I'm making a fake game to learn C#. I'm using classes to define my monsters.

//class.cs public class Monster { // instance variables... public int monsterNum; public string monsterName; public int monsterStrength; //constructor... public Monster(int monsterNum, string monsterName; int monsterStrength) this.monsterNum = monsterNum; this.monsterName = monsterName; this.monsterStrength = monsterStrength; } // and in my Program.cs... Monster snake = new Monster(1, "Snake", 10); Monster centaur = new Monster(2, "Centaur", 15); Monster mummy = new Monster(3, "Mummy", 20); Monster dragon = new Monster(4, "Dragon", 40); 

If my player is put under a spell and can't tell what he's looking at, how do I change ALL Monster instances' monsterName strings to "Unknown Creature" in one call or one method?

I thought it would be something super simple like Monster.monsterName = "Unknown Creature" but for the life of me I can't figure it out.

Thanks in advance for the help! You guys on this community are amazing!

by gavinrendar via /r/csharp

Leave a Reply