Re: [問題] arrary 如何 public

看板C_Sharp作者 (奈燦)時間11年前 (2012/10/18 19:06), 編輯推噓2(202)
留言4則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《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)

10/18 21:53, , 1F
不是 我是自己在看 head first c sharp 的書
10/18 21:53, 1F

10/18 21:53, , 2F
在做 dog race 的題目
10/18 21:53, 2F

10/18 21:55, , 3F
可以了!! 謝謝你
10/18 21:55, 3F

10/19 08:21, , 4F
加油!
10/19 08:21, 4F
文章代碼(AID): #1GV-BFtL (C_Sharp)
討論串 (同標題文章)
文章代碼(AID): #1GV-BFtL (C_Sharp)