C# 4.0 Console项目使用Console.writeline失败,但未使用Console.readline
我有一个小示例程序,当它到达第50行时会中断,并显示“Error CS1513:}expected”。这是典型的,除了我一遍又一遍地计算花括号的数量,没有发现任何错误。有人告诉我,问题可能是我使用关键字和类声明的位置,但我并没有发现任何错误 我想知道我是否犯了错误。这是整个计划,;如果有任何不同,请与SharpDevelop一起编写C# 4.0 Console项目使用Console.writeline失败,但未使用Console.readline,c#-4.0,sharpdevelop,C# 4.0,Sharpdevelop,我有一个小示例程序,当它到达第50行时会中断,并显示“Error CS1513:}expected”。这是典型的,除了我一遍又一遍地计算花括号的数量,没有发现任何错误。有人告诉我,问题可能是我使用关键字和类声明的位置,但我并没有发现任何错误 我想知道我是否犯了错误。这是整个计划,;如果有任何不同,请与SharpDevelop一起编写 using System; namespace Problem { public class ClassA { public st
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;
}
}
}
}
使用系统;
名称空间问题
{
甲级公共课
{
公共静态void Main(字符串[]args)
{
ClassB MyObject=新的ClassB();
方法a();
}
}
公共B类
{
公共字符串str_a=“”;
公共字符串str_b=“”;
公共字符串str_c=“”;
公共bool bool_a=假;
公共整数[]整数a=新整数[6];
公开无效方法a()
{
while(str_a==“”| | str_a==null)
{
字符串str_a2=Console.ReadLine();
如果(str_a2==“”| | str_a2==null)
{
}
其他的
{
str_a=str_a2;
}
}
而(str_c==“”)
{
String str_c2=Console.ReadLine();
如果(str_c2==“”| | str_c2==null)
{
}
其他的
{
str_c=str_c2;
}
}
while(bool_a==false)
{
Console.WriteLine(“”;//编译失败,在此处要求结束括号
对于(int i=0;i<6;i+=1)
{
int_a[i]=0;
}
bool_a=真;
}
}
}
}
我敢肯定你可能是UNICODE引号的受害者
ʺ ̋“”″"
尝试删除双引号字符并在代码编辑器中键入它们!经典错误!我在while循环中有一个声明:
while {
public int[] int_b = new int[6];
}
很抱歉,所以。我曾经有过这样的一天……我试过,但那不是问题所在。我有一个不同的问题,答案是我有Unicode引号,所以我确保在提问之前我会检查所有我能检查的东西。你是否在visual studio中尝试过这个,因为我尝试过这个,它工作得很好。没有,但它在我谈论的另一个论坛上解决了。我在下面贴出了原因。你在说什么?问题中的代码中没有这样一行!!!做一个回滚,你就会看到它。就在我认为可能是错误之前,我把它拿了出来。我只是不想做回滚,因为我已经解决了错误,没有必要再把它放到主页上。