Checking the values passed into a method?

Posted on 2007-10-10
Last Modified: 2011-09-20
I am passing around 10 values into a method and I was wondering is there a built in way to ensure that all 10 values have been passed in / not null?

I am looking to avoid having a massive if statement or block of statements.

Question by:directxBOB
    LVL 7

    Expert Comment

    Use array or list, then loop through it and check?
    LVL 25

    Accepted Solution

    Are all of the types nullable? (strings, objects, or nullable value types like "int?")

    You could do some slick thing like putting all of the values into an array and looking for null within the array, but you're going to have to add all of the values so it won't buy you much.

    You could create a parameter class to hold the the values and check for null values within the class.

    Author Comment

    Bit the bullet and made my own class with the values.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    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 video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 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

    9 Experts available now in Live!

    Get 1:1 Help Now