generic input object example?

Posted on 2012-09-06
Medium Priority
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
  • 3
  • 2

Assisted Solution

user_n earned 1000 total points
ID: 38373522
LVL 55

Accepted Solution

Jaime Olivares earned 1000 total points
ID: 38374889
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
ID: 38375042
I just noticed you have specified both Java and C#. Which is the specific language you are targeting?

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 1 hour left to enroll

839 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