generic input object example?

Posted on 2012-09-06
Last Modified: 2012-09-07
I am trying to create a input class object to store different input variables so that I can always pass this input object only as a parameter to number of methods I have.

CalculateSomethingMethod1(MyInputObject myInputobject) {


CalculateSomethingMethod2(MyInputObject myInputobject) {


I have a lot of calculation methods with a lot of input parameters (4-12) and I am trying to create a generic input class so I can store those input paramenters.

Is there any examples I can look?

I am going to store, objects, string, integer, and double.
Question by:dkim18
    LVL 9

    Assisted Solution

    LVL 9

    Expert Comment

    LVL 9

    Expert Comment

    LVL 55

    Accepted Solution

    There are many options for this. You can pass a array or List of objects (List allows you to dynamically increase the list). So, you can derive your class from that list:

    public MyInputObject : List<object>
        // some implementation here, if needed

    then you can use it as:

    MyInputObject o = new MyInputObject();
    o.Add("some string");

    LVL 55

    Expert Comment

    by:Jaime Olivares
    I just noticed you have specified both Java and C#. Which is the specific language you are targeting?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

    761 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

    7 Experts available now in Live!

    Get 1:1 Help Now