Glen Ford wrote: > > Has else anyone noticed the following on mono 1.1.16.1 ... > > Hashtable table = new Hashtable(); > int myvalue = (int)table[32]; > > Generates an exception: > > Unhandled Exception: System.NullReferenceException: Object reference not > set to an instance of an object > > > However the following doesn't ... > > Hashtable table = new Hashtable(); > string myvalue = (string)table["blah"]; > > > I would have expected a NullReferenceException in the second case as well.
Same happens on .NET. First one is an unbox operation and unboxing requires an instance (it's a valuetype). Second is a cast operation. ((string)null) is perfectly valid. -- Carlo Kok _______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
