Search Results

Search found 1 results on 1 pages for 'user1303781'.

Page 1/1 | 1 

  • Where to declare variable? C#

    - by user1303781
    I am trying to make an average function... 'Total' adds them, then 'Total' is divided by n, the number of entries... No matter where I put 'double Total;', I get an error message. In this example I get... Use of unassigned local variable 'Total' If I put it before the comment, both references show up as error... I'm sure it's something simple..... namespace frmAssignment3 { class StatisticalFunctions { public static class Statistics { //public static double Average(List<MachineData.MachineRecord> argMachineDataList) public static double Average(List<double> argMachineDataList) { double Total; int n; for (n = 1; n <= argMachineDataList.Count; n++) { Total = argMachineDataList[n]; } return Total / n; } public static double StDevSample(List<MachineData.MachineRecord> argMachineDataList) { return -1; } } } }

    Read the article

1