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
Post a Comment