c#,求该报错的解决方案

来源:百度知道 编辑:UC知道 时间:2024/05/27 05:58:29
using System;
class NamedWelcome {
public static void Main(string[] args) {
Console.WriteLine("Hello, {0}!", args[0]);
Console.WriteLine("Welcome to the C# Station Tutorial!");}}

我用Microfoft Visual C# .NET,系统报错
, args[0]);
报错内容:
无效的表达式项“”
应输入 )
应输入 ;
无效的表达式项“)”
应输入 ;

请高手指点
改逗号为英文后还是报错了:
未处理的“System.IndexOutOfRangeException”类型的异常出现在 NamedWelcome.cs.exe 中。

其他信息: 索引超出了数组界限。

还是一楼的高手啊。同意一楼的,你这个是传入参数。比如命令行下xxx.exe -r -r 就是参数..
你这个就不能按常规调试的(虽然你的半角逗号页有错).
你要是想实现你那种功能你可以这样
using System;
class NamedWelcome {
public static void Main(string[] args) {
string x=Console.ReadLine();
Console.WriteLine("Hello,0}!",x);
Console.WriteLine("Welcome to the C# Station Tutorial!");}}

但是你要是按你原来那样调试的话页可以,在VS的DEBUG页面的Command line Arguments设置中加入参数..、、

晕,难道你没看到我说的么?

using System;
class NamedWelcome
{
public static void Main(string[] args)
{
Console.WriteLine("Hello, {0}!", args[0]);
Console.WriteLine("Welcome to the C# Station Tutorial!");}}

就好了。
注意符号大小写

class NamedWelcome {
public static void Main(string[] args) {
Console.WriteLine("Hello, {0}!", args[0]);
Console.WriteLine("Welcome to the C# Station Tutorial!");}}
///
Console.WriteLine("Hello, {0}!