int是值类型,不能为null;
int是“可空int”,是引用类型,可以为null。
using System;
using SystemCollectionsGeneric;
using SystemLinq;
using SystemText;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Person p = new Person();
pAge = null;
pAge2 =null;
}
}
public class Person
{
public int Age
{
get;
set;
}
public int Age2
{
get;
set;
}
为空还需要约束吗,不去insert就好了。当然也可以添加约束:
ALTER TABLE PersonsALTER COLUMN City SET DEFAULT ''
参考:>
以上就是关于怎么给int数据类型赋值为null全部的内容,包括:怎么给int数据类型赋值为null、Sql数据库检查约束中,约束int类型默认值为空,表达式怎么写、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)