I want to use the code i have and turn it into a function that i can call in the main program. I have to do a similar function a second time and want to be able to call them into the main program instead of having one big long list of code.
Itried this . . but im really not sure what i should be doing . ..
namespace differenceofmeans
{
public class TraceSet
{
public void Main()
{
TraceAverages;
{
Console.Write(avrg);
}
}
public static TraceAverages (float avrg)
{
string file = System.IO.File.ReadAllText(@"C:\Users\40025634\Desktop\Project\TraceSet.csv");
ArrayList rows = new ArrayList(file.Split('\n'));
{
foreach (string row in rows)
{
string r = row.Remove(row.Length - 1, 1);
ArrayList rowVals = new ArrayList(r.Split(','));
float sum = 0;
float addedItems = 0;
foreach (string item in rowVals)
{
try
{
float num = float.Parse(item);
sum += num;
addedItems++;
}
catch (Exception)
{
//throw;
}
}
if (addedItems > 0)
{
float avrg = sum / addedItems;
ArrayList avrgvalues = new ArrayList();
avrgvalues.Add(avrg);
}
return avrg;
Console.ReadKey();
}
}
}
}
}
Any help would be appriciated .