Xml Serialization vs. “True” and “False”

前端 未结 10 1090
傲寒
傲寒 2021-01-07 20:23

I\'m having an issue with deserializing an XML file with boolean values. The source XML files I\'m deserializing were created from a VB6 app, where all boolean values are c

10条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-07 20:51

    You could read that value as a string into a string field, then have a readonly bool field that had an if statement in it to return bool true or false.

    For example (using c#):

    public bool str2bool(string str)
    {
      if (str.Trim().ToUpper() == "TRUE")
          return true;
      else
          return false;
    }
    

    And you can use it in the template:

    
    

提交回复
热议问题