On 24 Oct 2013, at 10:31, Robert Jordan <[email protected]> wrote:

> Jonathan,
> 
> On 23.10.2013 17:37, [email protected] wrote:
>> What is the recommended way to create an instance of a nullable type, such 
>> as System.Nullable<int64>?
>> 
>> I would prefer a method that used the embedded API as opposed to a C# helper 
>> method.
>> 
> 
> There is still no API for this, AFAIK, so you must resort to
> using System.Type.MakeGenericType().
> 
It looks as if instantiating a System.Nullable<T> at runtime is not possible 
due to the distinct boxing behaviour of System.Nullable:

http://msdn.microsoft.com/en-US/library/ms228597(v=VS.80).ASPX
http://stackoverflow.com/questions/8691601/creating-a-nullable-object-via-activator-createinstance-returns-null
http://blogs.msdn.com/b/somasegar/archive/2005/08/11/450640.aspx

A boxed Nullable<T> consists of a boxed instance of the underlying type or a 
NULL pointer but NOT an instance of Nullable<T>.

I had thought, because of the above, that simply setting an int? as (MonoObject 
*)&intValue would work.
However, this doesn't seem to be the case. So more thought required on this.

Jonathan

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to