"类,结构或接口成员声明中的无效标记'{'"

Ane*_*kar 3 c# token

我在以下C#代码中收到错误"类,结构或接口成员声明中的无效标记'{".

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static int a, b;
        void add(int x, int y);
        {
            int c= x+y;
            Console.WriteLine("addition is " + char);
        }

        static void Main(string[] args)
        {   

        }
   }
}
Run Code Online (Sandbox Code Playgroud)

非常感谢您对解决方案的帮助.

谢谢.

ANEES

Zbi*_*iew 6

有错误,因为你有分号,并且有错误的变量名,修复:

void add(int x, int y)
{
    int c= x+y;
    Console.WriteLine("addition is " + c);
}
Run Code Online (Sandbox Code Playgroud)