c#五个自然日 工作日计算_C#程序输入工作日编号并打印工作日
c#五個自然日 工作日計算
從工作日編號打印工作日名稱 (Printing weekday name from weekday number)
A switch statement allows checking a variable/value with a list of values (cases) and executing the block associated with that case.
switch語句允許使用值(案例)列表檢查變量/值,并執行與該案例關聯的塊。
Weekday number is the number value from 0 to 6, 0 for "Sunday", 1 for "Monday", 2 for "Tuesday", 3 for "Wednesday", 4 for "Thursday", 5 for "Friday" and 6 for "Saturday". We will input a value between 0 to 6 and check with a switch statement.
工作日數字是從0到6的數字值, “星期日” 為 0 , “星期一” 為1,“星期二” 為2,“星期三” 為3,“星期四” 為4,“星期五” 為 5,“ 6”為數字。星期六” 。 我們將輸入一個介于0到6之間的值,并使用switch語句進行檢查。
C#代碼從給定的工作日編號(0-6)打印工作日名稱 (C# code to print weekday name from given weekday number (0-6))
Here, we are asking for an input of the weekday number (from 0 to 6) and print the weekday based on the given input using switch statement.
在這里,我們要求輸入星期幾(從0到6),并使用switch語句根據給定的輸入打印星期幾。
// C# program to input weekday number and print the weekday using System; using System.IO; using System.Text;namespace IncludeHelp {class Test{// Main Method static void Main(string[] args){int wday;//input wday numberConsole.Write("Enter weekday number (0-6): ");wday = Convert.ToInt32(Console.ReadLine());//validating using switch caseswitch (wday){case 0:Console.WriteLine("It's SUNDAY");break;case 1:Console.WriteLine("It's MONDAY");break;case 2:Console.WriteLine("It's TUESDAY");break;case 3:Console.WriteLine("It's WEDNESDAY");break;case 4:Console.WriteLine("It's THURSDAY");break;case 5:Console.WriteLine("It's FRIDAY");break;case 6:Console.WriteLine("It's SATURDAY");break;//if no case value is matcheddefault:Console.WriteLine("It's wrong input...");break;}//hit ENTER to exit the programConsole.ReadLine();}} }Output
輸出量
First run: Enter weekday number (0-6): 0 It's SUNDAYSecond run: Enter weekday number (0-6): 4 It's THURSDAYThird run: Enter weekday number (0-6): 6 It's SATURDAYFourth run: Enter weekday number (0-6): 9 It's wrong input...翻譯自: https://www.includehelp.com/dot-net/input-weekday-number-and-print-the-weekday-example-in-c-sharp.aspx
c#五個自然日 工作日計算
總結
以上是生活随笔為你收集整理的c#五个自然日 工作日计算_C#程序输入工作日编号并打印工作日的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: scanf 输入十六进制_在C语言中使用
- 下一篇: 日期getUTCMonth()方法以及J