Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace TestConsole
- {
- using System;
- using System.Collections;
- using System.Collections.Generic;
- public class Collection
- {
- private Dictionary<Type, IList> _dict;
- public Collection()
- {
- _dict = new Dictionary<Type, IList>();
- }
- public void Add<T>(T item)
- where T : IKek
- {
- var list = GetList<T>();
- list.Add(item);
- }
- public List<T> GetList<T>()
- where T : IKek
- {
- if (_dict.TryGetValue(typeof(T), out var list))
- {
- return list as List<T>;
- }
- var newList = new List<T>();
- _dict.Add(typeof(T), newList);
- return newList;
- }
- }
- public interface IKek
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement