好吧,這是一個奇怪的。垃圾數據也不是隨機的,它似乎是可執行文件本身的子字符串。異常導致字符串(C#)中的垃圾數據
private void Form1_Load(object sender, EventArgs e)
{
string s = GetValue();
// at this point, s == "400". Why isn't really relevant (dumbed down a test)
if (s != "18446744073709551615")
throw new Exception();
// When the exception is thrown though, the string is set to random
// data from inside the executable.
}
這似乎依賴於一定的GetValue看似微不足道的實施細則()如的String.format()的調用在不同的地方是。
有沒有人遇到類似的東西或有任何想法可能會導致此?
我認爲你應該包括GetValue()的定義,不管它多長時間 – 2008-10-08 03:24:19
另一個大問題是你如何檢查數據的「s」,更重要的是「何時」你檢查數據?在引發異常並且「s」現在超出範圍之後,您是否檢查它? – 2008-10-08 03:32:39
是的,這是VS彈出後,它是未處理的異常的東西。雖然我不記得以前發生過的局部變量。 – 2008-10-08 03:34:36