C#语法错误,似乎没什么错

时间:2015-09-26 00:57:51

标签: c# syntax-error

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

namespace SchoolPasswordLockFolder
{
    public class Program
    {
        public static void Main(string[] args)
        {
           Console.WriteLine("Enter the password: "); // the space character after the semicolon has an error
            public string input = Console.ReadLine();

        }
    }
}

错误:

Severity    Code    Description Project File    Line
Error   CS1513  } expected  SchoolPasswordLockFolder    c:\Users\CENSOREDSIJGIOFSGJIOFS\documents\visual studio 2015\Projects\App5\SchoolPasswordLockFolder\SchoolPasswordLockFolder\Program.cs 14

(对于分号后面的那个) 和

Severity    Code    Description Project File    Line
Error   CS1022  Type or namespace definition, or end-of-file expected   SchoolPasswordLockFolder    c:\Users\CENSOREDIDONTWANTSTALKERS\documents\visual studio 2015\Projects\App5\SchoolPasswordLockFolder\SchoolPasswordLockFolder\Program.cs  19

(最后一个括号) 我没有用C#编程很长时间,因为我太忙于网络开发和lua ...

1 个答案:

答案 0 :(得分:5)

改变这个:

public string input = Console.ReadLine();

为:

string input = Console.ReadLine();

局部变量不会获得public等可访问性修饰符。