C# typ identifikátora existuje, ale ja som ešte stále chybu, že sa to očakáva [zatvorené]

0

Otázka

Píšem môj prvý c# algoritmus výzvou a ja som sa dostanete do problému. Pridal som typ identifikátory, aby všetky moje premenných, ale ja som ešte stále chybu, že identifikátor je v poriadku. Nie som si istý, ako môžem riešiť to, keď skutočný typ identifikátora je tam. Tu je môj kód a tu je chyba, keď sa prihlásite.

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

dlhé a krátke sú typy, používať rôzne názvy pre tieto premenné.

2021-11-23 18:57:33
1

"dlhé" a "short" sú boths kľúčové slová pre typy (dlhý, že 64-bitové celé číslo, a krátke sú 16 bitové jeden). Zmeniť názvy "dlhé" a "short" premenných na niečo iné, ako "longValue" a "shortValue".

Viac sa dočítate tu.

2021-11-23 18:57:50

V iných jazykoch

Táto stránka je v iných jazykoch

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