title: How to access properties from an array of class objects in C#?
body: <pre><code>    Character[] PlayerOne = new Character[5];
  
      PlayerOne[1] = new BladeWarrior();
      PlayerOne[2] = new FistWarrior();
      PlayerOne[3] = new Archer();
      PlayerOne[4] = new RedMage();
      PlayerOne[5] = new BlueMage();  
  </code></pre>
  
  <p>I know through polymorphism, a BladeWarrior can be a Character but it cant be the other way around. My problem is that when I try to access an element of an array. Player[1] for example, I cant access functions and variables from the BladeWarrior class. It's only letting me access variables and functions from the Character class which the BladeWarrior class inherits from.</p>
  
  <p>I'm going to need to be able to access Bladewarrior functions/variables if Im going to want 2 characters to fight.</p>
  
  <p>I was thinking I could use the "as" function to set PlayerOne[1] as the specific object . Not exactly like this:</p>
  
  <pre><code>string s = objArray[i] as string;
  </code></pre>
  
  <p>The line of code above is just to get an idea of which "as" Im talking about.</p>
  
  <p>What is a solution to this problem?</p>