久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為什么輸入“int"永遠不等于“空"?

Why type quot;intquot; is never equal to #39;null#39;?(為什么輸入“int永遠不等于“空?)
本文介紹了為什么輸入“int"永遠不等于“空"?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

int n == 0;

if (n == null)    
{  
    Console.WriteLine("......");  
}

表達式 (n == null) 的結果是否總是 false 因為
 int  類型的值永遠不等于  null 類型 int?(見下面的警告)

Is it true that the result of expression (n == null) is always false since
a   value of type int  is never equal to   null of type int? (see warning below)

警告 CS0472 表達式的結果始終為false",因為int"類型的值永遠不會等于int"類型的null"?

Warning CS0472 The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type 'int?'

推薦答案

如果您希望整數變量允許空值,請將其聲明為 可空類型:

If you want your integer variable to allow null values, declare it to be a nullable type:

int? n = 0;

注意 int 之后的 ?,這意味著該類型可以具有值 null..NET Framework v2.0 引入了可空類型.

Note the ? after int, which means that type can have the value null. Nullable types were introduced with v2.0 of the .NET Framework.

這篇關于為什么輸入“int"永遠不等于“空"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 国产高清在线精品一区二区三区 | 午夜一区二区三区视频 | 中文字幕日韩欧美 | a黄视频 | 免费v片 | 福利社午夜影院 | 国产亚洲高清视频 | 麻豆视频在线免费观看 | 人成在线视频 | 国产精品久久国产精品99 gif | 中文字幕视频在线观看 | 福利视频二区 | 国产精品久久久久久久久久久久 | 亚洲天堂精品久久 | 中文字幕国产精品 | 国产成人小视频 | 荷兰欧美一级毛片 | 亚洲欧美国产一区二区三区 | 女女爱爱视频 | 国产黄色在线 | 粉嫩av久久一区二区三区 | 亚洲精品久久久久久一区二区 | 91在线视频免费观看 | 99视频入口 | 国产午夜精品久久久久 | 久久精品久久久久久 | 97超碰人人草 | 久久五月婷| 91精品久久久久久久久久 | 免费成人高清在线视频 | 久久精品91久久久久久再现 | 午夜免费在线观看 | 国产福利二区 | 免费一区 | 在线免费观看黄a | 激情婷婷成人 | 九九亚洲精品 | 精品国产1区2区3区 一区二区手机在线 | 九九精品热 | 狠狠婷婷综合久久久久久妖精 | 伊人影院99 |