我有一个小的示例程序,当它到达第 50 行时中断,并显示"错误 CS1513:} 预期"。这是典型的,除了我一遍又一遍地计算大括号的数量,没有发现任何错误。 我在另一个论坛上被告知,问题可能是我在 using 关键字和类声明的位置,但我找不到任何错误。
我想知道我是否犯了错误。 这是整个程序;用SharpDevelop编写,如果它有任何区别。
using System;
namespace Problem
{
public class ClassA
{
public static void Main(string[] args)
{
ClassB MyObject = new ClassB();
MyObject.MethodA();
}
}
public class ClassB
{
public String str_a = "";
public String str_b = "";
public String str_c = "";
public bool bool_a = false;
public int[] int_a = new int[6];
public void MethodA()
{
while (str_a == "" || str_a == null)
{
String str_a2 = Console.ReadLine();
if (str_a2 == "" || str_a2 == null)
{
}
else
{
str_a = str_a2;
}
}
while (str_c == "")
{
String str_c2 = Console.ReadLine();
if (str_c2 == "" || str_c2 == null)
{
}
else
{
str_c = str_c2;
}
}
while (bool_a == false)
{
Console.WriteLine(""); //Fails to compile, asks for ending brackets here
for (int i = 0; i < 6; i += 1)
{
int_a[i] = 0;
}
bool_a = true;
}
}
}
}
我很
确定你可能会成为UNICODE引号的受害者。
ʺ ̋“”″"
尝试删除双引号字符并在代码编辑器中键入它们。
Doh! 经典错误! 我在一段时间循环中有一个声明:
while {
public int[] int_b = new int[6];
}
对此感到抱歉,所以。 我有这样的日子...