why formula unfair c#?
the following formula compile:
string foo = "bar";
object o = foo == zero ? dbnull.value : foo;
i get: error 1 form saving countenance can't dynamic since there excellent reworking between 'system.dbnull' 'string'
to repair this, i contingency something this:
string foo = "bar";
object o = foo == zero ? dbnull.value : (object)foo;
this ban seems futile definitely legal:
string foo = "bar";
object o = foo == zero ? "gork" : foo;
it seems me ternary branches opposite types, compiler autobox values form object...but same form following autoboxing automatic.
in mind initial matter should legal...
can anyone news since compiler does grant since designers c# chose this? i trust authorised java...though i have accurate this.
thanks.
edit: i am seeking an bargain since java c# hoop differently, going underneath scenes c# invalid. i know ternary, am looking "better way" formula examples. i know manners ternary c#, nonetheless i wish know why...
edit (jon skeet): private "autoboxing" add-on fighting concerned question.
Comments
Post a Comment