I have an interface that looks like this
public interface SomeInterface<T, U>
where T : struct
where U : class
{
void Method1();
IDictionary<T, BaseClassItem<U>> GetDictionary();
}
I have one of the implementations like this
public class LruEvictor<T, U> : SomeInterface<T, U>
where T : struct
where U : class
{
private Dictionary<T, BaseClassItem<U>> _dictionary;
public void Evict()
{
}
public IDictionary<T, BaseClassItem<U>> GetDictionary()
{
_dictionary = new Dictionary<T, BaseClassItem<U>>();
return _dictionary;
}
}
In the above GetDictionary() method I would like to return a dictionary of
type Dictionary<T, DerivedItem<U>>.
Is that possible? If yes how do I do it.
Given below is the derived class implementation.
public class DerivedItem<U> : BaseClassItem<U>
where U : class
{
public DerivedItem(U value) :base(value)
{
}
public DateTime LastAccessed { get; private set; }
public override void OnAccessed()
{
LastAccessed = DateTime.Now;
}
}
Any input will be appreciated.
Thanks in advance.