Solved

Passing a Double parameter that has no value

Posted on 2006-06-14
4
237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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