看板 C_Sharp 關於我們 聯絡資訊
※ 引述《largesperm (reindeer)》之銘言: : 不好意思 我剛接觸 C# 如果問題問的不對 還請見諒 : 我新增了一個 MyClass.cs : 我在 Form1.cs 裡面寫道 : namespace MyNameSpace : { : public partial class Form1 : Form : { : public Form1() : { : InitializeComponent(); : } : private void button1_Click(object sender, EventArgs e) : { : MyClass[] classes = new MyClass[4]; : MyClass[0].MyProp = 1; ^^^^^^^^^^^^^^^^^^ 你的myclass沒有設static的話這裡會噴錯 : } 你的MyClass看起來是要當全域變數 你如果宣告在click裡的話他click完就沒有用了 照這個程式碼你應該要宣告在 public partial class Form1 : Form { //這裡左右C public XXX{..... //不是這 } private void butto(){ //也不是這 } } 另外...這是作業嗎(? -- εξ ●-ζ ●- -●/ ( <■> ■ Keep smoking......∕) /\ 〒) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.32.144.249 ※ 編輯: Ansaga 來自: 114.32.144.249 (10/18 19:08)
largesperm:不是 我是自己在看 head first c sharp 的書 10/18 21:53
largesperm:在做 dog race 的題目 10/18 21:53
largesperm:可以了!! 謝謝你 10/18 21:55
Ansaga:加油! 10/19 08:21