How to create a System.Nullable<T> instance? #139
Unanswered
bluewave41
asked this question in
Q&A
Replies: 1 comment 3 replies
-
@bluewave41 const NullableInt32 = mscorlib.class("System.Nullable`1").inflate(mscorlib.class("System.Int32"));
const object = NullableInt32.alloc();
// way 1
object.method(".ctor").invoke(1);
// way 2
object.field("value").value = 1;
object.field("has_value").value = true;
// later on, if you need to use it as a struct:
const unboxed = new Il2Cpp.ValueType(object.unbox(), object.class.type); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is what I'm hoping to accomplish but this of course doesn't work as System.Nullable<T> is a struct and not a class. I don't see any obvious methods on the Image class that would help me out here. What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions