Skip to content

Instantly share code, notes, and snippets.

@rousso
Created March 5, 2013 08:50
Show Gist options
  • Save rousso/5088886 to your computer and use it in GitHub Desktop.
Save rousso/5088886 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Text;
namespace TestGenerics
{
class Program
{
static void Main(string[] args)
{
MyList myList = new MyList();
myList.Add(1);
myList.Add(2);
myList.Add(3);
myList.Print();
Console.WriteLine("Now the 2nd List");
My2ndList my2ndList = new My2ndList();
my2ndList.Add(1);
my2ndList.Add(2);
my2ndList.Add(3);
my2ndList.Print();
}
}
public class MyList : List<int>
{
new private void Add(int item)
{
item *= 10;
base.Add(item);
}
public void Print()
{
foreach (int item in this)
Console.WriteLine(item.ToString());
}
}
public class My2ndList : MyList
{
new private void Add(int item)
{
item *= 100;
base.Add(item);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment