Reputation: 3546
I Have a class
class ExpiryList
{
protected ConcurrentDictionary <GenericType, DateTime> m_list;
ExpiryList(GenericType obj, DateTime expiryDate)
{
m_list.AddOrUpdate(obj, expiryDate, (x, y) => { return expiryDate; });
}
}
And i am wondering how to implement this? I need a way to create an instance of this class that stores either int, string, String, double etc... into the GenericType variable.
Upvotes: 3
Views: 772
Reputation: 87228
You can make your class generic:
class ExpiryList<TAnyType>
{
protected ConcurrentDictionary <TAnyType, DateTime> m_list;
ExpiryList(TAnyType obj, DateTime expiryDate)
{
m_list.AddOrUpdate(obj, expiryDate, (x, y) => { return expiryDate; });
}
}
Upvotes: 5
Reputation: 887275
You're trying to create a generic class:
public class ExpiryList<T>
Upvotes: 3