浅析C# Main参数输入问题

开发 后端
我们在C# Main参数学习的过程中会遇到什么问题呢?那么这里就向你介绍了C# Main参数输入的问题,希望对你了解和学习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参数输入问题有所帮助。

【编辑推荐】

  1. C#从C和C++继承的特点浅谈
  2. 浅谈C#向Java学习的体现
  3. C# Main函数概念以及应用祥解
  4. C# Main方法概述及特点解析
  5. C# main函数应用实例详解
责任编辑:仲衡 来源: JavaEye
相关推荐

2009-08-28 15:57:56

C#线程传递参数

2009-08-24 14:51:25

C# 泛型泛型类型

2009-09-07 03:23:40

C# Main方法

2009-08-17 13:26:20

C#调用Windows

2009-08-21 14:03:04

C#网络编程

2009-08-24 15:02:05

C# 类型

2009-08-17 18:34:50

C# ChangeCo

2009-08-14 17:45:52

C# ArrayLis

2009-08-07 17:25:37

C# SortedLi

2009-08-11 09:16:00

2009-08-25 17:59:49

C#入门

2009-08-24 10:07:57

C#泛型处理

2009-08-18 10:30:30

C#枚举

2009-08-11 14:45:41

C# DataGrid

2009-08-10 14:43:03

C#函数Convert

2009-09-11 09:15:06

C# get方法

2009-07-31 16:00:30

C#函数重载

2009-08-04 09:30:33

C#调用ImageAn

2009-08-21 17:24:06

C# SingleIn

2009-08-20 10:10:55

C#透明窗体
点赞
收藏

51CTO技术栈公众号