Re: [問題] 副程式裡面呼叫需要傳回值的副程式

看板C_Sharp (C#)作者 (King)時間20年前 (2005/09/24 09:29), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
※ 引述《tomex (tomex_ou)》之銘言: : g1, h1可當參數傳入abc(),如: : int abc(g1, h1) : { : p = MapToPoint(g1); : h = MapToIntHours(h1); : } : 至於p, h怎麼回傳,其實該副程式要繼續寫下去 : 將最後的結果傳回來即可。 : 若仍覺得不好用,這代表你method設計不當,再好好想想模組的概念。 可是我現在在我的button按鈕下編寫下列程式碼 private void button1_Click(object sender, System.EventArgs e) { string g1,h1; double ans=0; h1 = textBox1.Text; g1 = textBox5.Text; CalculateGPA(); textBox10.Text = ans.ToString(); } static void CalculateGPA() { int p=0,h=0; p = MapToPoint(g1); h = MapToIntHours(h1); } 編譯的時候卻跟我說 The name 'g1' does not exist in the class or namespace 'GPA.Form1' The name 'h1' does not exist in the class or namespace 'GPA.Form1' 怎麼會這樣呢? -- 因看板太多不可能逐一觀看 麻煩各位回覆文章的時候也請順便回覆到我的信箱 http://blog.xuite.net/kingtw1978/blog -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 70.173.83.247
文章代碼(AID): #13DAlW9_ (C_Sharp)
文章代碼(AID): #13DAlW9_ (C_Sharp)