How to make a nullable type?

Feb 28, 2015 at 7:13 PM
Edited Feb 28, 2015 at 7:43 PM
Hello,
I am trying to make a dictionary which the value is a nullable type.
I wrote a code like this.(ValType is defined with C# code)
int=clr.System.Int32
null=clr.System.Nullable
dic=clr.System.Collections.Generic.Dictionary

a=dic[int,null[Namespace.ValType]]()
I wanted the type of a to become Dictionary<int,Valtype?>,but it becomes Dictionary<int,List<ValType>> when I look at it by debugger.
How do I make a nullable type?
Feb 28, 2015 at 8:45 PM
Hello,

it seems, that you missed a clr before Namespace.Value.
dic = clr.System.Collections.Generic.Dictionary
null = clr.System.Nullable
a = dic[clr.System.Int32, null[clr.System.Int32]]
print(a)
System.Collections.Generic.Dictionary`2[
  [System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],
  [System.Nullable`1[
    [System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
  ], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
]
Mar 1, 2015 at 9:48 AM
Sorry, I forgot clr when I simplyfied code for this question.
It doesn't work even the type is correct.

I found that this code works good,
a =clr.System.Collections.Generic.Dictionary[clr.System.Int32, clr.System.Nullable[clr.System.Int32]]
print(a)
System.Collections.Generic.Dictionary`2[
    [System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],
    [System.Nullable`1[
        [System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
    ], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
]
But this code makes a list instead of nullable.
s= clr.System.Collections.Generic.List[clr.System.String]
a =clr.System.Collections.Generic.Dictionary[clr.System.Int32, clr.System.Nullable[clr.System.Int32]]
print(a)
print(s)
System.Collections.Generic.Dictionary`2[
    [System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],
    [System.Collections.Generic.List`1[
        [System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
     ], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
]

System.Collections.Generic.List`1[
    [System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
]
I am using 0.9.12.0
Mar 1, 2015 at 7:51 PM
Fixed in 0.9.13.0.
Cache rule was wrong.

Thank you for sending me this bug.
Mar 2, 2015 at 10:39 AM
My code is working now.
Thank you!