我有這個解決方案,我正在努力並試圖將3個不同的 問題的userInput返回給Main。這是我目前的。從方法中返回三個值
public static string GetInput()
{
//declared variables
string userInput;
string outputTitle;
Console.Write("Enter your name: ");
userInput= Console.ReadLine();
Console.Write("Enter your age: ");
userInput = Console.ReadLine();
Console.Write("Enter the Gas Mileage: ");
userInput = Console.ReadLine();
return userInput;
}
我有它設置我從來沒有獲得通過的方式(「輸入您的姓名」);題。什麼是更好的方式去做這件事?
userName = InputUtilities.GetInput(userName); //錯誤2方法'GetInput'沒有超載需要1個參數
Console.Write(「Your name is:{0}」,userName);
你要什麼這個方法返回? – Zeeshan
此方法與Main不同。我想獲取名稱並將其返回到Main以顯示。然後隨着年齡增加,然後耗油量。 – floyd