Cast object to Decimal nullable

L

Luigi

Hi all
how can I write a method that returns me true if is possible to cast an
object to decimal nullable and false if not?
Like

public bool CanConvert(object obj)
{

return true if obj is possible to cast to decimal nullable
return false if not

}

Thanks a lot.
 
J

Jon Skeet [C# MVP]

how can I write a method that returns me true if is possible to cast an
object to decimal nullable and false if not?
Like

public bool CanConvert(object obj)
{
return true if obj is possible to cast to decimal nullable
return false if not
}

public bool CanConvert(object obj)
{
return obj is decimal || obj == null;
}
 

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