【发布时间】:2010-02-18 22:05:04
【问题描述】:
我有下一个代码:
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?为什么在这种情况下分配了currency 而分配了amount - 不是?
【问题讨论】:
-
查看此问题了解更多信息:stackoverflow.com/questions/1542824/…
标签: c# .net struct unassigned-variable