Skip to content

Instantly share code, notes, and snippets.

@crowcoder
Created August 22, 2016 23:14
Show Gist options
  • Save crowcoder/eb40c2679a919d7fcc9acf474a50d4b7 to your computer and use it in GitHub Desktop.
Save crowcoder/eb40c2679a919d7fcc9acf474a50d4b7 to your computer and use it in GitHub Desktop.
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