Can anybody know what to do to with (error CS1525: Unexpected symbol)

927 Views Asked by At

I'm fighting with this problem from yesterday and I don't know what is the problem. On my MacBook code is running without problems. I have Visual Studio Code. But after action "copy and paste" to internet compiler on https://pl.spoj.com code have a crush. Compiler is gmcs 5.20.1 for C#.

Code: https://ideone.com/359Iuw

using System;

public class Test
{
    public static void Main()
    {
        int numberOfTests;
            int[] arrayOfNumbers = new int[100];
            string[] splittedData;
            int firstNumber, secondNumber;
            double wynik;

            // Step 1. Read and upload numbers of repetitions
            numberOfTests = TakeNumberOfTests();
            // Step 2. Calculations
            for (uint i = 0; i < numberOfTests; i++)
            {
                splittedData = PodzielBufor(PobierzBufor(),' ');
                firstNumber = TakeNumber(splittedData,1);
                secondNumber = TakeNumber(splittedData,2);
                wynik = NWW(firstNumber,secondNumber);
                Console.WriteLine("{0}",wynik);
            }


            // All functions 
            int TakeNumberOfTests()
            {
                int ans = Int.Parse(Console.ReadLine());
                return ans;
            }

            int NWD(int a, int b)
            {
                int zmiennaPomocnicza;
                while(b!=0)
                {
                    zmiennaPomocnicza = b;
                    b = a%b;
                    a = zmiennaPomocnicza;
                }
                return a;
            }

            double NWW(int a, int b)
            {
                double result;
                result = (a*b)/NWD(a,b);
                return result;
            }
            string PobierzBufor()
            {
                return Console.ReadLine(); //odczyt danych ze strumienia
            }
            string[] PodzielBufor(string inputData, char character)
            {
                string[] splittedData;
                splittedData = inputData.Split(character);
                return splittedData;
            }
            int TakeNumber(string[] dataArray,int number)
            {
                return Int32.Parse(dataArray[number-1]);
            }
    }
}

Can anybody give me advice what I need to do?

1

There are 1 best solutions below

1
On BEST ANSWER

You are using a language feature from a higher version of C# than is on the remote compiler.

  1. Find out what language version the online compiler supports; possibly 6 or 5 if it doesn't support local functions (you may need to use trial and error if they don't make it clear)
  2. Set the language version in your project; now your own compiler locally will tell you if you try to use anything not supported; in new (SDK-style) csproj this is via <LangVersion>6<LangVersion> etc (in the csproj inside a property-group)