C# 我不断地犯同样的错误;CS1525:意外符号`字符串'&引用;。我只能';我找不到我哪里出错了

C# 我不断地犯同样的错误;CS1525:意外符号`字符串'&引用;。我只能';我找不到我哪里出错了,c#,compiler-errors,C#,Compiler Errors,我只想说我对编程比较陌生,所以我对这些错误不太了解,不管怎样,这是我的代码,我经常遇到“意外符号字符串”错误: using System; class MainClass { public static void Main (string[] args) { Console.WriteLine ("Welcome to the Mushroom Kingdom bank. The Only bank in The World That Converts Real Money

我只想说我对编程比较陌生,所以我对这些错误不太了解,不管怎样,这是我的代码,我经常遇到“意外符号字符串”错误:

using System;

class MainClass {
  public static void Main (string[] args) 
  {

    Console.WriteLine ("Welcome to the Mushroom Kingdom bank. The Only bank in The World That Converts Real Money to Gold Coins!");

    int pass1 = 1900;
    int pass2 = 85;
    Console.WriteLine("Please enter the password, so we can confirm you are a real person.");
    Console.WriteLine($"The password is {pass1} plus {pass2}");
    Console.WriteLine("Please enter the password");
    string userPass = 
    Console.ReadLine();
    string correctPass = "1985";
    bool answer = userPass == correctPass;
    Console.WriteLine(answer);

    if (userPass == correctPass) 
    {
      Console.WriteLine("Please Choose An Option");
    } 
    else 
    {
      Console.WriteLine("Incorrect, Restart Progtam");

    }
      Console.WriteLine("Your starting balance is 200 gold coins. This converts to 288 US Dollars");
      Console.WriteLine("-> Deposit <-");
      Console.WriteLine("-> Withdraw <-");


      double CoinValue = 1.44;
      double coinBalance = 200

      string userChoice = Console.ReadLine();
      userChoice.ToUpper();

    if (userChoice == "DEPOSIT")
    {
    Console.WriteLine("Enter an amount to deposit");
    string depamount = Console.ReadLine();
    double dubamount = Convert.ToDouble(depamount);
    double nxtBalance = (dubamount / CoinValue) + coinBalance;
    Console.WriteLine($"{depamount} has been converted to {CoinValue} gold coins.");

    }
    else if (userChoice== "WITHDRAW")
    {
    Console.WriteLine("Enter an amount to withdraw");
    string widamount = Console.ReadLine();
    double dubwidamount = Convert.ToDouble(widamount);
    double widcoin = dubwidamount / CoinValue;
    double newBalance = coinBalance - widcoin;
    Console.WriteLine($"You have withdrawed {widcoin} gold coins from your account. Your remaining balance is {coinBalance} gold coins");



    }



  }
}
使用系统;
类主类{
公共静态void Main(字符串[]args)
{
Console.WriteLine(“欢迎来到蘑菇王国银行。世界上唯一一家将真实货币兑换成金币的银行!”);
int pass1=1900;
int pass2=85;
WriteLine(“请输入密码,以便我们确认您是真人。”);
WriteLine($“密码是{pass1}加上{pass2}”);
Console.WriteLine(“请输入密码”);
字符串userPass=
Console.ReadLine();
字符串correctPass=“1985”;
bool answer=userPass==correctPass;
控制台。写线(应答);
if(userPass==correctPass)
{
Console.WriteLine(“请选择一个选项”);
} 
其他的
{
Console.WriteLine(“不正确,重新启动程序”);
}
Console.WriteLine(“您的起始余额为200金币,转换为288美元”);

Console.WriteLine(“->存款支取以下行中有错误,您错过了分号

双倍余额=200

顺便说一句,代码中有错误,可能是

字符串userChoice=Console.ReadLine().ToUpper()

因为string.ToUpper()函数返回字符串,但不处理字符串的安装

但仍然不是,比如在土耳其的位置,大写的“存款”将变成“DEPOSİT”,其中“i”变成“İ”,所以这是不正确的(你永远不应该知道,这里99%的开发者,只有经验) 正确的比较是:

if(string.Compare(userChoice,“存款”,StringComparison.InvariantCultureIgnoreCase)==0)


下一行中有个错误,您遗漏了分号

双倍余额=200

顺便说一句,代码中有错误,可能是

字符串userChoice=Console.ReadLine().ToUpper()

因为string.ToUpper()函数返回字符串,但不处理字符串的安装

但仍然不是,比如在土耳其的位置,大写的“存款”将变成“DEPOSİT”,其中“i”变成“İ”,所以这是不正确的(你永远不应该知道,这里99%的开发者,只有经验) 正确的比较是:

if(string.Compare(userChoice,“存款”,StringComparison.InvariantCultureIgnoreCase)==0)


正如@Oleg指出的,您缺少行终止符。您收到的
字符串
错误来自以下行:

double coinBalance = 200 // this line isn't terminated

string userChoice = Console.ReadLine(); // compiler doesn't understand where the string type is coming from
修正:


正如@Oleg指出的,您缺少行终止符。您收到的
字符串
错误来自以下行:

double coinBalance = 200 // this line isn't terminated

string userChoice = Console.ReadLine(); // compiler doesn't understand where the string type is coming from
修正:


删除不必要的文本并使您的问题更正式。删除不必要的文本并使您的问题更正式。
string userPass=
实际上是两行有效的
string userPass=Console.ReadLine()
问题只是
cointBalance
上的终止符。
cointBalance
后面的一行正在实例化一个
字符串
,但编译器不喜欢它,因为
cointBalance
行没有正确终止。@quaabaam抱歉,在这个例子中它是有效的,但不是必需的。我一直在考虑你的问题我也是,但在看到你的帖子后就抓到了。
stringuserpass=
实际上是两行,这是有效的
stringuserpass=Console.ReadLine()
问题只是
cointBalance
上的终止符。
cointBalance
后面的一行正在实例化一个
字符串
,但编译器不喜欢它,因为
cointBalance
行没有正确终止。@quaabaam抱歉,在这个例子中它是有效的,但不是必需的。我一直在考虑你的问题nes也是,但在看到你的帖子后发现了它。