c# - #if region does not work -


i wanna use #if statement skip serializing val when val2 true , serialize val when val2 false. code seems not work:

#if val2     [xmlignore] #else        [xmlelement(elementname = "val")] #endif public bool val {     { get; set; } = false; }  [xmlelement(elementname = "val2")] public bool val2 {     { get; set; } = true; } 

what have working? thanks

just add 1 of following code, , val won't serialized, when val2 true:

public bool shouldserializeval() {     return val2 == false; } 

or

public bool shouldserializeval() {     return !val2; } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -