Which is preferred: new Nullable<int> or (int?)null ?

Posted by abatishchev on Stack Overflow See other posts from Stack Overflow or by abatishchev
Published on 2010-04-29T17:43:35Z Indexed on 2010/04/29 17:47 UTC
Read the original article Hit count: 179

Filed under:
|
|
|
|

Which way is preferred in expressions like this:

int? Id
{
   get
   {
      int i;
      return Int32.TryParse(Request["id"], out i) ? i : (int?)null;
   }
}

is it better to cast on null or create a new Nullable<T> ?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#