Creating a nullable type using Activator

G

Guest

Hi

I am trying to create an instance of a nullable type using System.Activator
for example

t is passed in from the caller and is the Type info for a nullable type or
can be a standard type i.e string, int etc.

object value = Activator.CreateInstance(t);

value always returns null
 
M

Mattias Sjögren

value always returns null

That makes sense since you haven't specified a value for the instance.


Mattias
 
G

Guest

Hi Giuseppe,

Thanks for the reply, this has helped me solve the problem. Thanks for your
help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top