次のコードがあります:
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) { }
そして次のエラーを取得します:
割り当てられていないローカル変数 'amount' の使用
なぜ私はそれを取得していて、これは合法なのamount
ですか? currency
この場合、なぜ割り当てられてamount
- ではないのですか?