Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Passing a Double parameter that has no value

Posted on 2006-06-14
4
Medium Priority
?
247 Views
Last Modified: 2012-05-05
I have a line of code that looks like so:

empGradeSale = empGradeSalHome.create(ref tempAux8, ref tempAux9, grdDto.EmpPySchdCd, ref tempAux10, ref null, ref null, ref null, ref null, ref null, ref null, grdDto.LastUpdatedBy);

My problem is the "ref null".  The method they are being passed to requires them to be doubles or longs.  In C# you can't convert nulls to doubles or longs.  What do you do when you want to pass a variable that is a double or long but it has no value?
0
Comment
Question by:adonavon
4 Comments
 
LVL 6

Expert Comment

by:PoeticAudio
ID: 16904043
I use double.MinValue and then have logic in the method (in your case empGradeSalHome.create) which tests against double.MinValue, if it is MinValue then it performs the logic needed as if it were null.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16904477
Is it a method that you have control over or is it third-party ? If you control it then the OO method would be to create an overload that doesn't require the unwanted parameters to be passed.
0
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 2000 total points
ID: 16904511
Are you using C# .NET 2? If so, you can have nullable value types in...

        public double? add(double? a, double? b)
        {
            return a + b;
        }
...
        double? sum = add(null, null);
0
 

Author Comment

by:adonavon
ID: 16904718
I was hoping there was a simpler way but if not then I have to take this approach.  If no one comes up with a simpler way by end of the day then the points are yours.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Screencast - Getting to Know the Pipeline
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question