G
Guest
Hi All,
I am trying to create a method that executes a parallel array and returns a
value. I am not sure why the method I wrote is generating an error. The error
is displayed as: Use of unassigned local variable retFinalPercentage. Please
look at the code below and offer your advice. Thanks
public static double SelectFinalPercent2(int imyFuture)
{
int[] aAge = {55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65};
double[] aPercent = {.37, .40, .43, .49, .55, .61, .67, .73, .82, .91,
1.0};
double retFinalPercentage;
for(int x = 0; x < aAge.Length; ++x)
{
if(imyFuture == aAge[x])
{
retFinalPercentage = aPercent[x];
x = aAge.Length;
}
}
return retFinalPercentage; //<-- Use of unassigned local variable
retFinalPercentage
}
I am trying to create a method that executes a parallel array and returns a
value. I am not sure why the method I wrote is generating an error. The error
is displayed as: Use of unassigned local variable retFinalPercentage. Please
look at the code below and offer your advice. Thanks
public static double SelectFinalPercent2(int imyFuture)
{
int[] aAge = {55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65};
double[] aPercent = {.37, .40, .43, .49, .55, .61, .67, .73, .82, .91,
1.0};
double retFinalPercentage;
for(int x = 0; x < aAge.Length; ++x)
{
if(imyFuture == aAge[x])
{
retFinalPercentage = aPercent[x];
x = aAge.Length;
}
}
return retFinalPercentage; //<-- Use of unassigned local variable
retFinalPercentage
}