How do I allow my CookieData
to be generic in the following code? I get an compile-time error on the declaration of ICookieService2
.
public struct CookieData<T>
{
T Value { get; set; }
DateTime Expires { get; set; }
}
public interface ICookieService2: IDictionary<string, CookieData<T>>
{
// ...
}
My error is:
The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
I am wanting ICookieService2
to have generic data inserted into it. Thanks!
Edit Won't that lock me into a single T
for the construction of any ICookieService2
?
Edit 2 What I am trying to do is the following:
CookieData<int> intCookie = { Value = 27, Expires = DateTime.Now };
CookieData<string> stringCookie = { Value = "Bob", Expires = DateTime.Now };
CookieService2 cs = new CookieService2();
cs.Add(intCookie);
cs.Add(stringCookie);