c# - How to structure this variable -
right form can send me 3 values boolean fields.
false true "" procedure.needsauditing = convert.toboolean(collection["needsauditing"]);
how structure variable if ""
not try convert boolean instead pass null
?
if want third state bool
indicates not determined(null
) can use nullable<bool>
.
so change property to:
public bool? needsauditing{ get; set; }
and assign in way:
object needsauditing = collection["needsauditing"]; if(needsauditing == null) procedure.needsauditing = (bool?) null; else procedure.needsauditing = convert.toboolean(needsauditing);
side-note: should consider use pascal case propertynames. see property naming guidelines.
Comments
Post a Comment