草庐IT

degenericed

全部标签

c# - 无法将 null 添加到可空列表

这个问题在这里已经有了答案:关闭12年前。PossibleDuplicate:AddingnulltoaListcastasanIListthrowinganexception.ListlistONullables=newList();IListdegenericed=listONullables;//ThisworksfinelistONullables.Add(null);//Runtimeexception://"Thevalue""isnotoftype"System.Nullable`1[System.Int32]"//andcannotbeusedinthisgeneric