Advertisement
MBrendecke

Levels

Mar 18th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. using System;
  2.  
  3. static class Program {
  4.   Level [] levels = new Level [10];
  5.   levels [0] = new Level1 ();
  6.  
  7.   foreach (var l in levels) {
  8.     if (l != null) {
  9.       Console.WriteLine(l.Name);
  10.     }
  11.   }
  12. }
  13.  
  14. abstract class Level {
  15.   public int Number { get; protected set; }
  16.   public String Name { get; protected set; }
  17. }
  18.  
  19. class Level1 : Level {
  20.   public Level1 () {
  21.     this.Number = 1;
  22.     this.Name = "Level 1";
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement