如何在C#中检查未定义的值/对象 [英] How to check for Undefined Values/Objects in C#
问题描述
我需要检查C#中未定义的值和对象,我应该使用哪个函数
。 (== null)对未定义的对象不起作用。
感谢
" =? UTF-8乙TS4gVXBwYWw = ="????; < MU **** @ discussions.microsoft.com>写在
新闻:54 ********************************** @ microsof t .com:我需要检查C#中的未定义值和对象,我应该使用哪个函数。 (== null)不适用于未定义的对象。
Null未定义。我只发现了很少的例子,由于转换
或覆盖,因此无法在C#中工作。
-
Chad Z .Hower(又名Kudzu) - http://www.hower.org/Kudzu/
编程是一种反击的艺术形式
使用IntraWeb支持ASP.NET
http://www.atozed.com/IntraWeb/
这是我的代码snipet不起作用
if(sObject [0] == null){sLen =" 0";} else {sLen =
sObject.Length.ToString();}
其中sObject [0]的值为< undefined value>
怎么回事?我做了这个工作。
谢谢,
M. Uppal
" Chad Z Hower aka Kudzu"写道:
" =?Utf-8?B?TS4gVXBwYWw =?=" < MU **** @ discussions.microsoft.com>在
新闻中写道:54 ********************************** @ microsof t.com:< blockquote class =post_quotes>我需要检查C#中的未定义值和对象,我应该使用哪个函数。 (== null)对未定义的对象不起作用。
Null未定义。我只发现了很少的例子,因为转换
或覆盖而无法在C#中工作。
-
Chad Z. Hower(又名Kudzu) - < a rel =nofollowhref =http://www.hower.org/Kudzu/target =_ blank> http://www.hower.org/Kudzu/
编程是一种艺术形式,反击
Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
" =?Utf-8?B ?TS4gVXBwYWw = =" < MU **** @ discussions.microsoft.com>写在
新闻:EB ********************************** @ microsof t .com:
这是我的代码snipet不起作用
if(sObject [0] == null){sLen =" 0" ;;} else {sLen =
sObject.Length.ToString();}
它的sObject [0]可能不是null,而是sObject本身。试试这个:
if(sObject == null){sLen =" 0" ;; } ...
-
-mdb
Hi, I need to check for undefined values and objects in C#, which function
should i use. (== null) does not work for undefined objects.
thanks
"=?Utf-8?B?TS4gVXBwYWw=?=" <MU****@discussions.microsoft.com> wrote in
news:54**********************************@microsof t.com:Hi, I need to check for undefined values and objects in C#, which
function should i use. (== null) does not work for undefined objects.
Null is undefined. I''ve only found a very few instances that ti doesnt work in C# due to conversions
or overrides.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Here is my snipet of code that doesnot work
if (sObject[0] == null) {sLen = "0";} else {sLen =
sObject.Length.ToString();}
where sObject[0] has value of <undefined value>
how else should i make this work.
thanks,
M. Uppal
"Chad Z. Hower aka Kudzu" wrote:
"=?Utf-8?B?TS4gVXBwYWw=?=" <MU****@discussions.microsoft.com> wrote in
news:54**********************************@microsof t.com:Hi, I need to check for undefined values and objects in C#, which
function should i use. (== null) does not work for undefined objects.
Null is undefined. I''ve only found a very few instances that ti doesnt work in C# due to conversions
or overrides.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
"=?Utf-8?B?TS4gVXBwYWw=?=" <MU****@discussions.microsoft.com> wrote in
news:EB**********************************@microsof t.com:
Here is my snipet of code that doesnot work
if (sObject[0] == null) {sLen = "0";} else {sLen =
sObject.Length.ToString();}
Its probably not sObject[0] that is null, but sObject itself. Try this:
if (sObject == null) { sLen = "0"; } .....
--
-mdb
这篇关于如何在C#中检查未定义的值/对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!