나는 다음 코드가 있습니다여러 번에 한 번에 할당되지 않은 지역 변수가 있습니까?
static void Main(string[] args)
{
byte currency;
decimal amount;
if (Byte.TryParse("string1", out currency) && Decimal.TryParse("string2", out amount))
{
Check(currency, amount);
}
Check(currency, amount); // error's here
}
static void Check(byte b, decimal d) { }
을하고 다음 오류가 발생합니다 :
Use of unassigned local variable 'amount'
왜 내가 전혀 무엇입니까이 왜에만 amount
에 대한 법적인가? 이 경우 currency
이 할당되고 amount
이 아닌 이유는 무엇입니까?
자세한 내용은이 질문을 참조하십시오. http://stackoverflow.com/questions/1542824/c-initialization-of-instance-fields-vs-local-variables – M4N