Why do I need to cast a generic type T
to object
first, before I can cast it to a bool
?
Can I constraint T
so that I can cast it to bool
directly?
e.g.
public void Set<T>(T value)
{
if (typeof (T) == typeof (bool))
{
Manager.SetValue(ID, (bool) (object) value);
}
// ...
}