C#一个简单的程序 helloworld 里面的一些问题
namespacepoint{classProgram{publicclassgreetings{publicstaticvoidEnglishGreeting(){Co...
namespace point
{
class Program
{
public class greetings
{
public static void EnglishGreeting()
{
Console.WriteLine("Hello World!");
}
public static void SpanishGreeting()
{
Console.WriteLine("Ciao,mondo!");
}
public static void ItaliamGreeting()
{
Console.WriteLine("Hola,imundo!");
}
delegate void greetingdele();
class hello
{
static void Main(string[] args)
{
int iChoice = int.Parse (args[0]);
greetingdele[] deletest =
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
deletest[iChoice -1]();
}
}
}
}
}
问题1:int.Parse(args[0])这句是什么意思?
问题2:deletest[iChoice-1]()是怎么一一访问到委托数组的元素的?
问题3:Main方法里的参数 string[] args 有什么用? 展开
{
class Program
{
public class greetings
{
public static void EnglishGreeting()
{
Console.WriteLine("Hello World!");
}
public static void SpanishGreeting()
{
Console.WriteLine("Ciao,mondo!");
}
public static void ItaliamGreeting()
{
Console.WriteLine("Hola,imundo!");
}
delegate void greetingdele();
class hello
{
static void Main(string[] args)
{
int iChoice = int.Parse (args[0]);
greetingdele[] deletest =
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
deletest[iChoice -1]();
}
}
}
}
}
问题1:int.Parse(args[0])这句是什么意思?
问题2:deletest[iChoice-1]()是怎么一一访问到委托数组的元素的?
问题3:Main方法里的参数 string[] args 有什么用? 展开
3个回答
展开全部
问题1:吧字符串型的数字变为整数型,如把字符串型"123"变成整数123
问题2:greetingdele[] deletest 定义了一个委托数组。deletest[iChoice -1]()其中的变量iChoice是重你的输入参数string[] args中获得的第一个参数(如果运行程序控制台需要你输入参数,如果你输入1那么就会调用委托数组中下标为0的函数)
问题3:string[] args 为字符串数组参数,接受的是用你从控制台巡行是输入的参数。(就好比你点开始->运行->输入cmd回车键入命令Regsvr32 Path,那么这个Path就会存储在args[0]中)
问题2:greetingdele[] deletest 定义了一个委托数组。deletest[iChoice -1]()其中的变量iChoice是重你的输入参数string[] args中获得的第一个参数(如果运行程序控制台需要你输入参数,如果你输入1那么就会调用委托数组中下标为0的函数)
问题3:string[] args 为字符串数组参数,接受的是用你从控制台巡行是输入的参数。(就好比你点开始->运行->输入cmd回车键入命令Regsvr32 Path,那么这个Path就会存储在args[0]中)
展开全部
greetingdele[] deletest =
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
可能要改成
greetingdele[] deletest =new greetingdele[]
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
吧
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
可能要改成
greetingdele[] deletest =new greetingdele[]
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
试运行了一下
程序有错误
程序有错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询