Identyfikator typu c# istnieje, ale nadal pojawia się komunikat o błędzie, który ma [zamknięte]

0

Pytanie

Piszę swoją pierwszą zadanie algorytmem c# i ma do czynienia z problemem. Dodałem identyfikatory typów do wszystkich swoich zmiennych, ale nadal pojawia się komunikat o błędzie, że ma identyfikator. Nie jestem pewien, jak mogę rozwiązać ten problem, gdy istnieje rzeczywisty identyfikator typu. Oto mój kod, a oto dziennik błędów.

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

długie i krótkie typy, używać różnych nazw dla tych zmiennych.

2021-11-23 18:57:33
1

"długi" i "krótki" - to oba słowa kluczowe dla typów (długi-64-bitowa liczba całkowita, a krótki-16-bitowe). Zmień nazwy zmiennych "long" i "short" na coś innego, na przykład "longValue" i "shortValue".

Więcej informacji znajdziesz tutaj.

2021-11-23 18:57:50

W innych językach

Ta strona jest w innych językach

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