討論串[問題] Closure的問題
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓3(3推 0噓 7→)留言10則,0人參與, 最新作者uranusjr (←這人是超級笨蛋)時間10年前 (2015/04/07 22:52), 10年前編輯資訊
0
0
0
內容預覽:
for (int i = 0; i < 10; i++) {. int localVariable = i;. btn[i].onClick += () => {. Console.WriteLine(localVariable.toString());. };. }. 這裡的問題是因為你只宣告了一
(還有433個字)

推噓1(1推 0噓 3→)留言4則,0人參與, 最新作者jamod (jasper)時間10年前 (2015/04/07 20:37), 10年前編輯資訊
0
0
0
內容預覽:
小弟覺得應該是發生Closure的問題吧?. 我想在10個按鈕上面掛10個觸發事件,Code大致上像:. for(int index = 0;index < 10;index++){. btn[index].onClick += () =>. {. Console.WriteLine(index.t
(還有1454個字)
首頁
上一頁
1
下一頁
尾頁