本文介绍了我有错误说明使用未分配的局部变量'n'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码: -



I've following code:-

int p, t, n;
decimal r;
double a;

p = Convert.ToInt32(txtLAmount.Text);
r = Convert.ToDecimal(lblroibuss);
r = r / 100;


if (Convert.ToDecimal(txtLyear.SelectedItem.Value) <= 1)
{
    t = 1;
}

else
{
    t = Convert.ToInt32(txtLyear.SelectedItem.Value);
}

if(lblprocfees.Text=="Annually")
{n=1;}
else if (lblprocfees.Text == "Quarterly")
{ n = 4; }
else if (lblprocfees.Text == "Monthly")
{ n = 12;
}

double temp = Convert.ToDouble(1 + (r / n));
double temp1 = n * t;
a = p * Math.Pow(temp, temp1);

    txtLAmmount.Text = Math.Round(a,2).ToString();







但它给了我错误使用未分配的局部变量'n'。无法理解为什么会发生这种情况,即使我已经宣布并在代码中指定'n'条件。



请帮助! :(




But it's giving me the error Use of unassigned local variable 'n'. Can't understand why this is happening even when I've declared and put on the condition in the code assigning 'n'.

PLease HELP!! :(

推荐答案


这篇关于我有错误说明使用未分配的局部变量'n'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 05:28