怎么给int数据类型赋值为null

怎么给int数据类型赋值为null,第1张

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 Persons

ALTER COLUMN City SET DEFAULT ''

参考:>

以上就是关于怎么给int数据类型值为null全部的内容,包括:怎么给int数据类型赋值为null、Sql数据库检查约束中,约束int类型默认值为空,表达式怎么写、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9770690.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-01
下一篇 2023-05-01

发表评论

登录后才能评论

评论列表(0条)

保存