using System.Collections.Generic;
static void Main(string[] args)
var bookInstance = new GenericClass<IBook, Book>();
bookInstance.AddToDictionary();
var movieInstance = new GenericClass<IMovie, Movie>();
movieInstance.AddToDictionary();
foreach (var item in GenericClass<IBook, Book>.dictionary)
Console.WriteLine("In GenericClass --- Key is: " + item.Key + " -- value is: " + item.Value);
var notGeniric = new NotGenericClass();
var notGeniric2 = new NotGenericClass();
notGeniric.AddToDictionary<IBook, Book>();
notGeniric2.AddToDictionary<IMovie, Movie>();
foreach (var item in NotGenericClass.dictionary)
Console.WriteLine("In NotGenericClass --- Key: " + item.Key+ "Value: " + item.Value );
public class GenericClass<TInterface, TClass>
public static Dictionary<Type, Type> dictionary = new Dictionary<Type, Type>();
public void AddToDictionary()
dictionary.Add(typeof(TInterface), typeof(TClass));
public class NotGenericClass
public static Dictionary<Type, Type> dictionary = new Dictionary<Type, Type>();
public void AddToDictionary<TInterface, TClass>()
dictionary.Add(typeof(TInterface), typeof(TClass));
public class Book : IBook { }
public class Movie : IMovie { }
public interface IMovie { }
public interface IBook { }