C# 标志枚举分隔符
我有一个枚举,并且
[Flags]
public enum SearchFilter
{
types = 0x01,
attributes = 0x02,
methods = 0x04
}
[System.Xml.Serialization.XmlAttribute("search-filter")]
public SearchFilter search_filter = SearchFilter.types | SearchFilter.attributes | SearchFilter.methods;
在序列化时它的成员类型结果属性将是这样的:
<filter search_filter="types attributes methods" />
但是需要属性:
<filter search_filter="types|attributes|methods" />
类序列化时如何更改分隔符?
I have an Enum and member it type
[Flags]
public enum SearchFilter
{
types = 0x01,
attributes = 0x02,
methods = 0x04
}
[System.Xml.Serialization.XmlAttribute("search-filter")]
public SearchFilter search_filter = SearchFilter.types | SearchFilter.attributes | SearchFilter.methods;
when serialize this class result attribute will be like that:
<filter search_filter="types attributes methods" />
but need attribute:
<filter search_filter="types|attributes|methods" />
how can change delimiter when class serializing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须完全控制它,然后 - 例如,我将该成员标记为
[XmlIgnore]
并添加公共string
属性,例如:You're going to have to take complete control of it, then - for example my marking that member as
[XmlIgnore]
and adding a publicstring
property such as: