Re: [問題] arrary 如何 public
※ 引述《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
10/18 21:53, 1F
→
10/18 21:53, , 2F
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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):