PC Review


Reply
Thread Tools Rate Thread

Cast object to Decimal nullable

 
 
Luigi
Guest
Posts: n/a
 
      31st Oct 2008
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.
--
Luigi
http://blogs.dotnethell.it/ciupaz/
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      31st Oct 2008
On Oct 31, 3:20*pm, Luigi <ciupazNoSpamGra...@inwind.it> wrote:
> 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;
}
 
Reply With Quote
 
Luigi
Guest
Posts: n/a
 
      3rd Nov 2008
"Jon Skeet [C# MVP]" wrote:

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


Perfect, thank you Jon.

Luigi
 
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
Absolute of decimal nullable Luigi Z Microsoft C# .NET 4 15th Jan 2009 06:07 PM
Round a decimal nullable Luigi Z Microsoft C# .NET 3 15th Jan 2009 03:22 PM
Decimal nullable problem Luigi Microsoft C# .NET 4 25th Sep 2008 10:41 AM
nullable type cast question DMG Microsoft C# .NET 2 26th Oct 2006 01:21 AM
Object/Decimal cast exception... Bug ? or is it me ? TheSteph Microsoft C# .NET 4 24th May 2006 04:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 AM.