Skip to content

Instantly share code, notes, and snippets.

@retran
Created October 1, 2018 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retran/9f4dc4c359d8e91d163e2452a642863c to your computer and use it in GitHub Desktop.
Save retran/9f4dc4c359d8e91d163e2452a642863c to your computer and use it in GitHub Desktop.
method hiding
using System;
namespace ConsoleApp1
{
class Foo
{
public void Do()
{
throw new InvalidOperationException();
}
}
class Bar : Foo
{
public new void Do()
{
Console.WriteLine("Hello World!");
}
}
class Program
{
static void Main(string[] args)
{
Foo foo = new Bar();
foo.Do();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment