淺析C# Main參數(shù)輸入問(wèn)題
C# Main參數(shù)輸入問(wèn)題是什么呢?我們?cè)趯?shí)際的開發(fā)學(xué)習(xí)當(dāng)中很多的碰到這樣的基礎(chǔ)的問(wèn)題,那么如何實(shí)現(xiàn)C# Main參數(shù)輸入問(wèn)題呢?讓我們看看具體的實(shí)現(xiàn)代碼。
C# Main參數(shù)輸入實(shí)例:
- 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("早上好,中國(guó)!");
- break;
- }
- Console.WriteLine("args[1]="+args[1]+" "+"args[1]="+args[2]);
- }
- }
- }
C# Main參數(shù)輸入問(wèn)題之程序中設(shè)定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("早上好,中國(guó)!");
- break;
- }
- Console.WriteLine("args[1]=" +
- args[1] + " " + "args[1]=" + args[2]);
- }
- catch
- {
- Console.WriteLine("執(zhí)行完畢!");
- }
- }
- 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參數(shù)輸入問(wèn)題的基本內(nèi)容就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C# Main參數(shù)輸入問(wèn)題有所幫助。
【編輯推薦】