---
# System prepended metadata

title: '[C#]判斷星期幾'
tags: [c#, Visual Studio, DateTime]

---

# [C#]判斷星期幾

###### tags: `c#` `DateTime` `Visual Studio`
> [time= 2019 11 07 ] 

> 原文 & 參考：
> https://king39461.pixnet.net/blog/post/269212351

<br>

```csharp=
private static string GetDayName () {
	DateTime today = DateTime.Now;
	switch (today.DayOfWeek) {
		case DayOfWeek.Monday:
			return "星期一";
		case DayOfWeek.Tuesday:
			return "星期二";
		case DayOfWeek.Wednesday:
			return "星期三";
		case DayOfWeek.Thursday:
			return "星期四";
		case DayOfWeek.Friday:
			return "星期五";
		case DayOfWeek.Saturday:
			return "星期六";
		case DayOfWeek.Sunday:
			return "星期日";
	}

	return "system error";
}
```