I am building a program that will run 10000 iterations on a 6 sets of numbers. These numbers after being put through the iterations and calculated out and sorted in the following fashion.
*_Set1_****_Set2_****_Set3_****_Set4_****_Set5****_Set6_*
*********************************************************
**DESC******DESC******DESC******DESC******DESC*****DESC**
*********************************************************
Where Set(n) is the set of numbers and DESC is descending order of the numbers.
I have tried doing a LIST. But I am very unfamiliar with LIST and I’m not even sure it’s what I’m looking for. I’ll give you an example of what I was doing with the LIST
//Created a Output Class for Sim
public class MC_OUT
{
public double output;
public double OOIP;
public double OGIP;
public double EURO;
public double EURG;
public double rAREA;
public double calcEURO;
public double calcEURG;
public MC_OUT(double output, double OOIP, double OGIP, double EURO, double EURG, double rAREA, double calcEURO, double calcEURG) {
this.output = output;
this.OOIP = OOIP;
this.OGIP = OGIP;
this.EURO = EURO;
this.EURG = EURG;
this.rAREA = rAREA;
this.calcEURO = calcEURO;
this.calcEURG = calcEURG;
}
//Declared list before Monte Carlo Sim.
List<MC_OUT> mcout = new List<MC_OUT>();
//Ran Code to Perform Calculations
//Then Executed this at End
if (OOIP >= 0 && OGIP >= 0)
{
mcout.Add(new MC_OUT(NormSInv((i - .5) / iter), OOIP, OGIP, EURO, EURG, rAREA, EURO / (rAREA * rNET_H * rGCF) * 1000, EURG / (rAREA * rNET_H * rGCF) * 1000));
}
//Then I got confused and couldn't figure out how to sort and then access the needed
//information
So I guess after all this junk my main question would be What is the most effective way to store this information and could someone please direct me to an appropriate tutorial?!
Thanks!
Now that you have created a list you can access the data by an index. For Example:
Or:
If you want to sort the data it can be as simple as this.
The above will sort the data based on one of the current properties you have. If you need to sort it differently you may need to think about adding another property to your object that would be better suited for sorting.
It is also easy to enumerate through the data with a foreach loop, or a for loop.
Collections are something very widely used, and there are numerous types!! You will want to get to know them, and how to use them. If you google C# collections you will get a lot of information/tutorials. Here’s an MSDN tutorial on collections. I could keep going on about how to access and use them, but there is really so much that you will need to dive in and start learning it through the information on the web. Hopefully the above examples, and links I have given you can get you started! Cheers!