Using .NET 3.5 and C# 3.0,
IList list = new List<bool?>();
list.Add(null);
This throws an ArgumentException, which just feels wrong.
List<bool?> list = new List<bool?>();
list.Add(null);
Works perfectly.
Is this a bug in Microsoft's code, then?
An example of how to produce this kind of error in a real-life situation:
new JavaScriptSerializer().Deserialize<List<bool?>>("[true, false, null]");
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…