PC Review


Reply
Thread Tools Rate Thread

Detect nullable types

 
 
=?Utf-8?B?ZWFjc3Vi?=
Guest
Posts: n/a
 
      3rd Apr 2006
How can i tell if a type is nullable or not.. is ther an IsNullable()
function somewhere?
 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      3rd Apr 2006
The Type class has an IsValueType property.

"eacsub" <(E-Mail Removed)> wrote in message
news2489088-3A9F-46BD-A910-(E-Mail Removed)...
> How can i tell if a type is nullable or not.. is ther an IsNullable()
> function somewhere?



 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      3rd Apr 2006

>How can i tell if a type is nullable or not.. is ther an IsNullable()
>function somewhere?


Something like

Type t = ...
bool nullable = t.IsGenericType &&
t.GetGenericTypeDefinition() == typeof(Nullable<>);


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Nullable types, nulls, reference & value types question. Roman Wagner Microsoft C# .NET 6 27th May 2009 10:39 PM
Re: Nullable types, nulls, reference & value types question. Göran Andersson Microsoft C# .NET 0 27th May 2009 12:57 PM
Re: Nullable types, nulls, reference & value types question. Göran Andersson Microsoft C# .NET 0 27th May 2009 12:57 PM
Re: Nullable types, nulls, reference & value types question. Roman Wagner Microsoft C# .NET 0 27th May 2009 08:22 AM
nullable types. why no support for nullable string Sakoulakis Microsoft C# .NET 3 6th Aug 2004 04:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 AM.