大家帮我看下代码:
using System;namespace Student.lesson.doworking
{
public class TestMain
{
public void Dg(out bool y)
{
y = false;
Console.WriteLine("请输入您的选择:1或0");
string inputStr = Console.ReadLine();
try
{
if(UInt32.Parse(inputStr) == 1)
{
y = true;
}else{
y = false;
}
}catch(Exception e){
Console.WriteLine("输入有误,请重新来过!");
this.Dg(out bool x);
}
}
public static void Main(string[] args)
{
Console.WriteLine("程序开始......");
TestMain tm = new TestMain();
bool is_post;
tm.Dg(out is_post);
Console.WriteLine(is_post);
}
}
}错误提示为:
D:\01>csc PersistInTheEnd.cs
Microsoft (R) Visual C# 2005 编译器 版本 8.00.50727.1433
用于 Microsoft (R) Windows (R) 2005 Framework 版本 2.0.50727
版权所有 (C) Microsoft Corporation 2001-2005。保留所有权利。PersistInTheEnd.cs(23,10): error CS1513: 应输入 }
PersistInTheEnd.cs(26,17): error CS1518: 应输入 class、delegate、enum、interface
或 struct
PersistInTheEnd.cs(26,34): error CS1001: 应输入标识符
PersistInTheEnd.cs(26,36): error CS1518: 应输入 class、delegate、enum、interface
或 struct
PersistInTheEnd.cs(29,22): error CS1518: 应输入 class、delegate、enum、interface
或 struct
PersistInTheEnd.cs(33,3): error CS1022: 应输入类型、命名空间定义或文件尾我的原本想用一个递归来操作一下这个返回值,程序的意思大体如下:我编写了一个从控制台获取输入的一行代码,如果用户输入了1则返回true以便进行下面的执行,如果输入的不是数字,那么会引发一个异常,我在处理异常时,进行了回调,让其重新输入新的数值,结着上述错误就发生了,请懂的人士帮忙分析一下,哪个地方错了呢?我暂时没有看出来,谢谢大家
using System;namespace Student.lesson.doworking
{
public class TestMain
{
public void Dg(out bool y)
{
y = false;
Console.WriteLine("请输入您的选择:1或0");
string inputStr = Console.ReadLine();
try
{
if(UInt32.Parse(inputStr) == 1)
{
y = true;
}else{
y = false;
}
}catch(Exception e){
Console.WriteLine("输入有误,请重新来过!");
this.Dg(out bool x);
}
}
public static void Main(string[] args)
{
Console.WriteLine("程序开始......");
TestMain tm = new TestMain();
bool is_post;
tm.Dg(out is_post);
Console.WriteLine(is_post);
}
}
}错误提示为:
D:\01>csc PersistInTheEnd.cs
Microsoft (R) Visual C# 2005 编译器 版本 8.00.50727.1433
用于 Microsoft (R) Windows (R) 2005 Framework 版本 2.0.50727
版权所有 (C) Microsoft Corporation 2001-2005。保留所有权利。PersistInTheEnd.cs(23,10): error CS1513: 应输入 }
PersistInTheEnd.cs(26,17): error CS1518: 应输入 class、delegate、enum、interface
或 struct
PersistInTheEnd.cs(26,34): error CS1001: 应输入标识符
PersistInTheEnd.cs(26,36): error CS1518: 应输入 class、delegate、enum、interface
或 struct
PersistInTheEnd.cs(29,22): error CS1518: 应输入 class、delegate、enum、interface
或 struct
PersistInTheEnd.cs(33,3): error CS1022: 应输入类型、命名空间定义或文件尾我的原本想用一个递归来操作一下这个返回值,程序的意思大体如下:我编写了一个从控制台获取输入的一行代码,如果用户输入了1则返回true以便进行下面的执行,如果输入的不是数字,那么会引发一个异常,我在处理异常时,进行了回调,让其重新输入新的数值,结着上述错误就发生了,请懂的人士帮忙分析一下,哪个地方错了呢?我暂时没有看出来,谢谢大家
{ public class TestMain
{
public void Dg(out bool y)
{
y = false;
Console.WriteLine("请输入您的选择:1或0");
string inputStr = Console.ReadLine();
try
{
if (UInt32.Parse(inputStr) == 1)
{
y = true;
}
else
{
y = false;
}
}
catch
{
Console.WriteLine("输入有误,请重新来过!");
Dg(out y); }
}
public static void Main(string[] args)
{
Console.WriteLine("程序开始......");
TestMain tm = new TestMain();
bool is_post;
tm.Dg(out is_post);
Console.WriteLine(is_post);
}
}
}
注意红字的地方