Re: [問題] 副程式裡面呼叫需要傳回值的副程式
※ 引述《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
討論串 (同標題文章)
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章