To make it short, I've got a method which look like this
public T GetCookie<T>(string key)
{
T obj;
if (typeof(T) == typeof(int))
{
return -1;
}
else
{
return default(T);
}
}
Why am I doing this ? The default value of an int
is 0
, and i need it to be -1
(I got a huge code sample based on that -1
), so i was wondering if something exists that could change the default value of an int
, or allow me to return an int
instead of my generic class.
I didn't find anything for now :/
Try doing something like: