【发布时间】:2011-01-25 11:58:23
【问题描述】:
我想序列化一个可以为空的布尔值,只需将其转换为字符串
public static string SerializeNullableBoolean(bool? b)
{
if (b == null)
{
return "null or -1 or .."; // What to return here?
}
else
{
return b.ToString();
}
}
将空值序列化为最合适的字符串是什么?
【问题讨论】:
-
感谢大家的意见!
-
肯定是:
true、false和FileNotFound! (向 DailyWTF 网站点头)。
标签: c# .net serialization nullable boolean