Solved

Passing a Double parameter that has no value

Posted on 2006-06-14
4
235 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing IIS after Visual Studio 2015 Community Edition 5 46
bulid json format 3 45
Two different visual studio versions 3 21
Reset asp.net login password 4 26
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
A short film showing how OnPage and Connectwise integration works.

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now