c# - JToken.ToObject giving same value again and again -


i have following method..

public void handle(jtoken jsontable)     {         var myvar = jsontable.toobject<abctable>();         // other code     } 

abctable structure:

public class abctable     {         public string column1         {             get;             set;         }        public string column2         {             get;             set;         }         public bool column3         {             get;             set;         }  } 

when call handle method-- jsontable has column1="a" , column2="b" , column3 not present.....

after going through .toobject(), myvar gets column3 = false along other 2 values

i need column3 = null after object formed..

any sincerely appreciated

thanks

as mentioned in comments, bool can not set null. variable create type bool automatically set false , not null. create boolean can set null, use nullable type bool?.

public bool? column3 {     get;     set; } 

now can set column3 do:

column3 = true; 

getting value bit more trivial:

if (column3.hasvalue) // check if column3 not null {     boo value = column3.value;     // process value here } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -