這是我第一次在這裏張貼了我的問題,我希望我能幫助:)簡單的靜態方法(控制檯)幫助
我的問題:
我想顯示「這老頭」(前兩個節只)在控制檯。 我開始學習方法,所以請忍受我的n00bishness。
歌曲是:
This old man, he played one
He played knick−knack on my thumb
With a knick−knack paddy−whack
Give a dog a bone
This old man came rolling home
This old man, he played two
He played knick−knack on my shoe
With a knick−knack paddy−whack
Give a dog a bone
This old man came rolling home
我編寫如下:
namespace Song
{
class Song
{
static void Main(string[] args)
{
doVerse(1);
doChorus();
}
static void doChorus()
{
Console.WriteLine("With a knick−knack paddy−whack");
Console.WriteLine("Give the dog a bone");
Console.WriteLine("This old man came rolling home");
Console.WriteLine();
Console.ReadLine();
}
static void doVerse(int verseNum)
{
string message = "";
message += "This old man, he played ";
message += verseNum;
message += ". \nHe played knick−knack ";
//message += getPlace(verseNum);
Console.WriteLine(message);
}
static void getPlace()
{
string message = "";
switch (verseNum)
{
case 1:
message = "on my thumb ";
break;
case 2:
message = "on my shoe";
break;
default:
message = "not yet defined";
break;
}
return message;
}
}
}
Visual Studio是給我下面的錯誤:
http://i56.tinypic.com/fx850m.jpg
我希望你們能理解我這個計劃的意圖。
感謝
問候,
凱爾:d
你的問題是什麼? – ChrisW 2010-09-03 10:05:48
那麼問題是什麼? – DHN 2010-09-03 10:05:54
看起來像'getPlace'需要'int verseNum'作爲參數 – mikej 2010-09-03 10:06:18