[問題] 請問一個執行序的問題

看板C_Sharp作者 (我愛吃蝦子)時間17年前 (2008/09/01 18:14), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
各位板友好 小弟現在在寫一個程式 .CS檔的程式碼如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; namespace WindowsApplication8 { public partial class Form1 : Form { int a = 0, b = 0,c=0; bool aa; public Form1() { InitializeComponent(); } public void count() { while (mythread2.IsAlive == true) { a++; label1.Text = a.ToString(); } } public void justsleep() { Thread.Sleep(5000); } ThreadStart mythreadstart1 = new ThreadStart(count); Thread mythread1 = new Thread(mythreadstart1); ThreadStart mythreadstart2 = new ThreadStart(justsleep); Thread mythread2 = new Thread(mythreadstart2); mythread1.Start(); mythread2.Start(); private void label1_Click(object sender, EventArgs e) { } } } 在debug的時候 會在 mythread1.Start();和mythread2.Start();這兩行出現以下的錯誤訊息: 類別、結構或介面成員宣告中無效的語彙基元 '(' 請問各位板友 小弟是否有哪裡搞錯了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.129.27.144

09/01 19:15, , 1F
因為你的程序不是寫在函式中
09/01 19:15, 1F
文章代碼(AID): #18ky2Nno (C_Sharp)