C # Get the current day of the week three ways to implement

Source: Internet
Author: User

Get the current day of the week to achieve this feature there are several ways, next will be listed 3 for your reference, interested you can not miss Ha, I hope the knowledge provided in this article is helpful to you

The first type:

string[] Day =New string[] {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };stringWeek = Day[convert.toint32 (DateTime.Now.DayOfWeek.ToString ("D"))]. ToString (); Lbday.text= Week;

The second type:

The third type:

  Public Static stringDT;  Public Static stringWeek; DT=DateTime.Today.DayOfWeek.ToString (); Switch(DT) { Case "Monday": Week="Monday";  Break;  Case "Tuesday": Week="Tuesday";  Break;  Case "Wednesday": Week="Wednesday";  Break;  Case "Thursday": Week="Thursday";  Break;  Case "Friday": Week="Friday";  Break;  Case "Saturday": Week="Saturday";  Break;  Case "Sunday": Week="Sunday";  Break; } Lbday.text= Week;

C # Get the current day of the week three ways to implement (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.