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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -