.NET学习笔记之Ado.NET 04

 int  n = null;  bool b=null; 错误:值类型不能复制为null值   int  ?n = null;  bool ?b=null;值类型赋值为null型 需要加?

string s = null;引用类型可以复制为null值

person.Age = result.GetInt32(2);  正确

person.Height = result.IsDBNull(3)?null:       (int ?)      result.GetInt32(3); 正确

person.Gender = (result.IsDBNull(4)?null:                   result.GetBoolean(4)); 错误

posted @ 2017-05-16 01:35  还不是因为你长的好看  阅读(76)  评论(0)    收藏  举报