我上课了
class ExpiryList
{
protected ConcurrentDictionary <GenericType, DateTime> m_list;
ExpiryList(GenericType obj, DateTime expiryDate)
{
m_list.AddOrUpdate(obj, expiryDate, (x, y) => { return expiryDate; });
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何实现这个?我需要一种方法来创建这个类的实例,它将int,string,String,double等存储到GenericType变量中.
你可以使你的类通用:
class ExpiryList<TAnyType>
{
protected ConcurrentDictionary <TAnyType, DateTime> m_list;
ExpiryList(TAnyType obj, DateTime expiryDate)
{
m_list.AddOrUpdate(obj, expiryDate, (x, y) => { return expiryDate; });
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
756 次 |
| 最近记录: |