RE: Check null or empty on it field

2011-10-19 Thread Paul Noone
ss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Shahram Banihashem Sent: Wednesday, 19 October 2011 10:40 PM To: ozMOSS Subject: Re: Check null or empty on it field This is the way I go: country = (item["Country"] ?? "No Country").ToString(); All in one l

Re: Check null or empty on it field

2011-10-19 Thread Shahram Banihashem
This is the way I go: country = (item["Country"] ?? "No Country").ToString(); All in one line, neat and easy!   Regards,   Shahram. From: Salman Ahmad To: ozmoss@ozmoss.com Sent: Wednesday, 19 October 2011 10:21 PM Subject: RE: Check null

RE: Check null or empty on it field

2011-10-19 Thread Salman Ahmad
ullOrEmpty(item["Country"].ToString())) { country = item["Country"].ToString(); } Regards, Salman Ahmad From: paul.no...@ceosyd.catholic.edu.au To: ozmoss@ozmoss.com Date: Wed, 19 Oct 2011 12:44:26 +1100 Subject: RE: Check null or empty on it field That looks great

RE: Check null or empty on it field

2011-10-18 Thread Paul Noone
That looks great Nigel thanks. And the null-coalescing operator checks both null and empty? From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Nigel Witherdin Sent: Wednesday, 19 October 2011 12:42 PM To: OzMoss Subject: RE: Check null or empty on it field Rather

RE: Check null or empty on it field

2011-10-18 Thread Nigel Witherdin
the same form can be used for different datatypes: DateTime someDate = (DateTime)(item["Date Field Name"] ?? DateTime.MinValue); Cheers, Nigel From: paul.no...@ceosyd.catholic.edu.au To: ozmoss@ozmoss.com Date: Wed, 19 Oct 2011 11:10:58 +1100 Subject: Check null or empty on it field

Check null or empty on it field

2011-10-18 Thread Paul Noone
Hi all, I'm trying to put some checks in place to avoid exceptions when a field has no value. I had tried null but it didn't seem to be enough. I'm now trying the following but continue to get an exception when a field in any item is empty. Is there a more robust way to do this? Check length as w