第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

(C# Forms) 劊子手游戲“argumentoutofrange”

(C# Forms) 劊子手游戲“argumentoutofrange”

C#
胡子哥哥 2021-06-03 15:41:47
當(dāng)我試圖顯示下劃線時,我試圖制作的劊子手游戲在 for 循環(huán)中拋出“ArgumentOutOfRangeException”。我嘗試重寫代碼,但沒有任何效果。            List<Label> underline;            int left = 300;            int top = 275;            for (int i = 0; i < data.solution.Length; i++) //data is the object that contains the word that is the solution            {                underline = new List<Label>();                underline[i].Parent = this;                underline[i].Text = "_";                underline[i].Size = new Size(35, 35);                underline[i].Location = new Point(left, top);                left += 30;                underline[i].Font = new Font(new FontFamily("Microsoft Sans Serif"), 20, FontStyle.Bold);            }我不明白這有什么問題。當(dāng)我點擊新游戲時它會立即拋出它。
查看完整描述

2 回答

?
心有法竹

TA貢獻1866條經(jīng)驗 獲得超5個贊

首先不要為 for 循環(huán)中的每次迭代創(chuàng)建一個新列表,而是在循環(huán)之外創(chuàng)建它。其次,您必須Label在列表中添加一個新實例,然后才能通過它的索引訪問它:


List<Label> underline = new List<Label>();

int left = 300;

int top = 275;


for (int i = 0; i < data.solution.Length; i++) //data is the object that contains the word that is the solution

{

    underline.Add(new Label());

    underline[i].Parent = this;

    underline[i].Text = "_";

    underline[i].Size = new Size(35, 35);

    underline[i].Location = new Point(left, top);

    left += 30;

    underline[i].Font = new Font(new FontFamily("Microsoft Sans Serif"), 20, FontStyle.Bold);

}


查看完整回答
反對 回復(fù) 2021-06-05
  • 2 回答
  • 0 關(guān)注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號