[Mono-dev] ChangeType for Nullable
Martin Baulig
martin at ximian.com
Mon Jun 19 10:40:48 EDT 2006
On Wed, 2006-05-24 at 09:31 -0700, tut wrote:
> Also i'd like to know if one of next expressions should return true:
>
> 1) typeof(int?).IsSubclassOf(typeof(Nullable<>))
> 2) typeof(int?).IsSubclassOf(typeof(Nullable))
Hello,
neither of these should return true.
2.) this is `System.Nullable' - ie. the non-generic static class - and
of course, no type can be a subclass of that.
1.) and again, you're comparing two different things:
typeof(int?) is an instantiated generic type while
typeof(Nullable<>) is the corresponding generic type definition; so
this doesn't work.
3.) typeof(int?).IsSubclassOf(typeof(Nullable<int>))
would be correct - comparing two instantiated generic types - but
typeof(int?) is actually an instance of Nullable<int> - and not
a subclass of it.
4.) typeof(int?) == typeof(Nullable<int>)
is true.
Martin
More information about the Mono-devel-list
mailing list