Hi am currently trying to get my c# console code to read from array and do some calculations. iv done most of it now. I am having a problem finding a year and calculating the standard deviation of the data.

The problem occurs when it checks the year array to see if it matchs the variable. Its asif it does not because it skips out the rest of the code in the case. My code is below, id be grateful if someone could look at it for any errors that may cause this

case 12:

Console.WriteLine();
Console.WriteLine("Please enter the year?");
year = Console.ReadLine();


float rainTotalCase12 = 0;
for (int i = 1; i < weatherData.GetLength(0); i++)
{
//match the year
if (weatherData[i, 0] == year) // PROBLEM IS HERE, IT WONT FIND THE YEAR
{
rainTotalCase12 = rainTotalCase12 + float.Parse(weatherData[i, 5]);
Console.WriteLine(rainTotalCase12);
}

// calculate the mean
float rainMeanCase12 = (float)rainTotalCase12 / weatherData.GetLength(0);

// calculate the variance
double rainVarianceCase12 = 0;
if (weatherData[i, 0] == year)
{
// variance is the squared sum of the differences between the
// rolled value and the mean of all the dice rolls
rainVarianceCase12 = rainVarianceCase12 +
((float.Parse(weatherData[i, 5]) - rainMeanCase12) * (float.Parse(weatherData[i, 5]) - rainMeanCase12));
}

// calculate the standard deviation (square root of the bias
// corrected variance)
double rainStdDevCase12 = Math.Sqrt(rainVarianceCase12 / (weatherData.GetLength(0) - 1));
Console.WriteLine("{0,-15:0}{1,-15:0}{2,-15:0}", "Total Rainfall", "Rainfall Mean", "Rainfall Standard Deviation ");
Console.WriteLine("{0,-15:0.0}{1,-15:0.0}{2,-15:0.0}", rainTotalCase12, rainMeanCase12, rainStdDevCase12);
Console.ReadLine();
}



break;