Created
August 22, 2016 23:14
-
-
Save crowcoder/eb40c2679a919d7fcc9acf474a50d4b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
namespace ConsoleApplication4 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var children = new List<Parent>(); | |
children.Add(new Child()); | |
children[0].Foo(); | |
ArrayList foos = new ArrayList(); | |
foos.Add(new Child()); | |
(foos[0] as Parent).Foo(); | |
Console.ReadKey(); | |
} | |
public class Parent | |
{ | |
public void Foo() | |
{ | |
Console.WriteLine("I'm the parent"); | |
} | |
} | |
public class Child : Parent | |
{ | |
public new void Foo() | |
{ | |
Console.WriteLine("I'm the child"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment