浅析C#Main参数输入问题

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

十余年专注成都网站制作,成都定制网页设计,个人网站制作服务,为大家分享网站制作知识、方案,网站设计流程、步骤,成功服务上千家企业。为您提供网站建设,网站制作,网页设计及定制高端网站建设服务,专注于成都定制网页设计,高端网页制作,对成都地磅秤等多个领域,拥有丰富的网站维护经验。

C# Main参数输入实例:

 
 
 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Text;  
  4.  
  5. namespace _04253  
  6. {  
  7. class hello  
  8. {  
  9. static void Main(string[] args)  
  10. {  
  11. switch (args[0])  
  12. {  
  13. case "老板":  
  14. Console.WriteLine("早上好,老板!");  
  15. break;  
  16. case "雇员":  
  17. Console.WriteLine("早上好,各位员工!");  
  18. break;  
  19. default:  
  20. Console.WriteLine("早上好,中国!");  
  21. break;  
  22. }  
  23. Console.WriteLine("args[1]="+args[1]+" "+"args[1]="+args[2]);  
  24. }  
  25. }  
  26. }  

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

 
 
 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Text;  
  4.  
  5. namespace _04253  
  6. {  
  7. class TestHello  
  8. {  
  9. static void Main(string[] args)  
  10. {  
  11. try 
  12. {  
  13. print();  
  14. switch (args[0])  
  15. {  
  16. case "老板":  
  17. Console.WriteLine("早上好,老板!");  
  18. break;  
  19. case "雇员":  
  20. Console.WriteLine("早上好,各位员工!");  
  21. break;  
  22. default:  
  23. Console.WriteLine("早上好,中国!");  
  24. break;  
  25. }  
  26. Console.WriteLine("args[1]=" +   
  27. args[1] + " " + "args[1]=" + args[2]);  
  28. }  
  29. catch 
  30. {  
  31. Console.WriteLine("执行完毕!");  
  32. }  
  33.  
  34. }  
  35.  
  36. static int i = 0;  
  37. static void print()  
  38. {  
  39. i++;  
  40. if (i == 1)  
  41. {  
  42. string[] s =new string[3];  
  43. s[0] = "老板";  
  44. s[1] = "雇员";  
  45. s[2] = "hello";  
  46. Main(s);  
  47.  
  48. }  
  49. else 
  50. return;  
  51.  
  52. }  
  53. }  
  54. }  

C# Main参数输入问题的基本内容就向你介绍到这里,希望对你了解和学习C# Main参数输入问题有所帮助。

网站标题:浅析C#Main参数输入问题
文章转载:http://www.hantingmc.com/qtweb/news21/547121.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联