作者kingtw1978 (King)
看板C_Sharp
标题Re: [问题] 副程式里面呼叫需要传回值的副程式
时间Sat Sep 24 09:33:35 2005
※ 引述《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