How to call a method at specific day in week in c#
In this pervious article, we have discussed How to call a method once time in a day in C# but if want to pass a method in a specify day
in week then we can use below code. Here we use dayof week
DayOfWeek:-
Seven days are in each week. We determine if a certain date is a Monday,
Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday. The DayOfWeek
property, and the DayOfWeek enum type, can be used for this purpose.
In C#
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public partial class specificdayinweek :
System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
DayOfWeek
today = DateTime.Today.DayOfWeek;
if(today
== DayOfWeek.Monday)
{
Response.Write("today
is Monday");
}
if
(today == DayOfWeek.Tuesday)
{
Response.Write("Today
is Tuesday");
}
if (today == DayOfWeek.Wednesday)
{
Response.Write("Today
is Wednesday");
}
if
(today == DayOfWeek.Thursday)
{
Response.Write("Today
is Thursday");
}
}
}
as we can use all seven days where we can our code we can put .
How to call a method at specific day in week in c#
Reviewed by NEERAJ SRIVASTAVA
on
6:01:00 PM
Rating:
No comments: