I want to emit dynamic method which is exactly the same as below:
void Foo(TimeSpan ts = default(TimeSpan))
By using ildasm, i can see it has been complied as nullref.
However from what i can get, if i want to achieve the same by Emit code, the method i can call named ParameterBuilder.SetConstant, and it will throw exception when the optional value type is TimeSpan.
I even decompiled SetConstant method, it handles DateTime explicitly(but not TimeSpan). Nullref is also not acceptable. From that code, it seems there's no way to set default(TimeSpan) as a default value.
Can anyone help?
Aucun commentaire:
Enregistrer un commentaire