using System.Collections.Generic;
public static void Main()
var myService = new MyService();
myService.AddToDictionary((new Model() { FirstName = "Joe", LastName = "Doe" }).GetType());
myService.DisplayDictionary();
private static readonly IDictionary<Type, ICollection<PropertyInfo>> _propertyDictionary = new Dictionary<Type, ICollection<PropertyInfo>>();
public void AddToDictionary(Type type)
ICollection<PropertyInfo> properties;
if (!_propertyDictionary.TryGetValue(type, out properties))
properties = type.GetProperties().ToList();
_propertyDictionary.Add(type, properties);
public void DisplayDictionary()
Console.Write(_propertyDictionary.ToArray()[0]);
public string FirstName {get; set; }
public string LastName { get; set; }