的錯誤是:CS0103: The name 'toAdresses' does not exist in the current context
名稱「toAdresses」不在當前情況下存在
在下面的代碼:
public bool myFunction()
{
string toAddress;
toAddress = "[email protected],[email protected]"; // for testing
int firstCharacter = toAddress.IndexOf(',');
if (firstCharacter != -1)
{
string[] toAdresses = toAddress.Split(',');
}
else
{
string[] toAdresses = new string[]{toAddress};
}
for (int i = 0; i < toAdresses.Length; i++) // here is the error with toAdresses.Length
{
// do this
}
}
感謝您的幫助!
可怕的變量命名:( –
如果你有興趣更多在編碼方面,Code Complete 2是一本很好的書,並討論了變量命名的重要性。如果你是一個剛開始學習的新開發人員,那麼這是帶有經驗的東西,沒有什麼會感到羞恥。 –