C#类型识别符的存在,但我仍然得到一个错误,它的预期[封闭]

0

的问题

我在写我的第一c#算法的挑战和我跑进一个问题。 我已经加入的类型标识到我所有的变量,但我仍然得到错误的识别符。 我不知道我如何能解决这个当的实际类型识别符的是存在的。 这里是我的代码这里是错误的记录。

public class ShortLongShort
{
  public static string Solution(string a, string b)
  {
    string long = a;
    string short = b;
    if(a.Length < b.Length) {
        short = a;
        long = b;
    }
    return short+long+short;
  }
}
src/Solution.cs(5,12): error CS1001: Identifier expected
src/Solution.cs(5,12): error CS1002: ; expected
src/Solution.cs(5,17): error CS1001: Identifier expected
src/Solution.cs(6,12): error CS1001: Identifier expected
src/Solution.cs(6,12): error CS1002: ; expected
src/Solution.cs(6,18): error CS1001: Identifier expected
src/Solution.cs(8,15): error CS1001: Identifier expected
src/Solution.cs(9,14): error CS1001: Identifier expected
src/Solution.cs(11,12): error CS1525: Invalid expression term 'short'
src/Solution.cs(11,18): error CS1525: Invalid expression term 'long'
src/Solution.cs(11,23): error CS1525: Invalid expression term 'short'
algorithm c#
2021-11-23 18:54:00
2
1

长期和短期的类型,使用不同的名称用于这些变量。

2021-11-23 18:57:33
1

"长期的"和"短期"是boths关键词用类型(长正在64位整数和简短的是16点之一)。 改变名称的"长"和"短期"变量,到别的东西,例如"longValue"和"shortValue".

读取更多的在这里。

2021-11-23 18:57:50

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................