473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Cast object to Decimal nullable

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/
Oct 31 '08 #1
2 5519
On Oct 31, 3:20*pm, Luigi <ciupazNoSpamGra...@inwind.itwrote:
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;
}
Oct 31 '08 #2
"Jon Skeet [C# MVP]" wrote:
public bool CanConvert(object obj)
{
return obj is decimal || obj == null;
}
Perfect, thank you Jon.

Luigi
Nov 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike | last post by:
I am using MS-Access as a front end for my MS-SQL DB. I have a sql view that uses the following: SELECT TOP 100 PERCENT RECID, PATNUMBER AS , SVCCODE AS , QTY, PROF_CHRGS AS , AMOUNT,...
4
by: John A. Bailo | last post by:
I call a web service using a dynamic assembly. Because of this, I have no way of knowing in advance, what the return object type of the service is. It may be an integer, it may be a string. ...
4
by: TheSteph | last post by:
Why do I get an exception "The specified cast is not valid" ??? Is that a bug or do I miss something ? object DecimalObject = 1; decimal TmpDecimal; TmpDecimal = (decimal)DecimalObject;
3
by: Dan Holmes | last post by:
i have a datareader that pulls a field of type numeric(18, 0). the debugger shows the field as {decimal}. I want to cast it to an int. This doesn't work (int)dr:. Is that because the definition...
5
by: Franky | last post by:
Can a Decimal variable be set to "Not a Number" I've been looking in the help and can't find any reference to that. Thanks in advance
3
by: Andrus | last post by:
public static bool Empty(object? obj) { return false; } public static bool Empty(string? obj) { return false; }
5
by: =?Utf-8?B?emlubw==?= | last post by:
in .net 2.0, the class (myClass) contains a property defined as: private _creationDate as As Nullable(Of DateTime) Public Property CreationDate() As Nullable(Of DateTime) Get If...
2
by: Rick | last post by:
I have a business object (class) with some nullable properties declared like this: Private _MyProp as Nullable(of Int16) public Property MyProp as Nullable(Of Int16) get Return _MyProp end...
3
by: Froefel | last post by:
Hi group I am creating a web application that uses a simple DAL as an ObjectDataSource. To retrieve data from the database, I use a DataReader object from which I then assign the various fields...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.