[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Passing a Double parameter that has no value

Posted on 2006-06-14
4
Medium Priority
?
243 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 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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