我認爲這個錯誤與If語句有關,但是我試過尋找錯誤,而且大部分問題都是由語法錯誤引起的,這對我來說似乎不是這樣。預先感謝您的幫助。爲什麼顯示無效的表達式項「字符串」?
using System;
namespace FirstConsoleProjectSolution
{
class MainClass
{
public static void Main (string[] args) // this is a method called "Main". It is called when the program starts.
{
string square;
string cylinder;
Console.WriteLine ("Please enter a shape");
if (string == square) {
double length;
double width;
double height;
Console.WriteLine ("Please enter length");
Console.ReadLine (Convert.ToDouble());
Console.WriteLine ("Please enter width");
Console.ReadLine (Convert.ToDouble());
Console.WriteLine ("Please enter height");
Console.ReadLine (Convert.ToDouble());
Console.WriteLine ("Your total volume is" + length * width * height);
}
if (string == cylinder) {
double areaOfBase;
double height;
Console.WriteLine ("Please enter area of base");
Console.ReadLine (Convert.ToDouble());
Console.WriteLine ("Please enter height");
Console.ReadLine (Convert.ToDouble());
Console.WriteLine ("Your total volume is" + areaOfBase * height);
}
}
}
}
謝謝你這麼多你得到的錯誤! – 2015-01-26 21:03:04