如何理解C# Main参数输入问题

发布时间:2021-06-16 14:43:13 作者:chen
来源:亿速云 阅读:133

这篇文章主要讲解了“如何理解C# Main参数输入问题”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“如何理解C# Main参数输入问题”吧!

C# Main参数输入问题是什么呢?我们在实际的开发学习当中很多的碰到这样的基础的问题,那么如何实现C# Main参数输入问题呢?让我们看看具体的实现代码。

C# Main参数输入实例:

using System;  using System.Collections.Generic;  using System.Text;   namespace _04253  {  class hello  {  static void Main(string[] args)  {  switch (args[0])  {  case "老板":  Console.WriteLine("早上好,老板!");  break;  case "雇员":  Console.WriteLine("早上好,各位员工!");  break;  default:  Console.WriteLine("早上好,中国!");  break;  }  Console.WriteLine("args[1]="+args[1]+" "+"args[1]="+args[2]);  }  }  }

C# Main参数输入问题之程序中设定args[]的值

using System;  using System.Collections.Generic;  using System.Text;   namespace _04253  {  class TestHello  {  static void Main(string[] args)  {  try {  print();  switch (args[0])  {  case "老板":  Console.WriteLine("早上好,老板!");  break;  case "雇员":  Console.WriteLine("早上好,各位员工!");  break;  default:  Console.WriteLine("早上好,中国!");  break;  }  Console.WriteLine("args[1]=" +   args[1] + " " + "args[1]=" + args[2]);  }  catch {  Console.WriteLine("执行完毕!");  }   }   static int i = 0;  static void print()  {  i++;  if (i == 1)  {  string[] s =new string[3];  s[0] = "老板";  s[1] = "雇员";  s[2] = "hello";  Main(s);   }  else return;   }  }  }

感谢各位的阅读,以上就是“如何理解C# Main参数输入问题”的内容了,经过本文的学习后,相信大家对如何理解C# Main参数输入问题这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

推荐阅读:
  1. C#基础总结(一)
  2. 如何理解C#中对于接口的实现方式

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

上一篇:C++ 中怎么利用string替换指定字符

下一篇:C++中this和static关键字的作用是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》