Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

get number of sundays in a month c#

static int NumberOfParticularDaysInMonth(int year, int month, DayOfWeek dayOfWeek)
{
    DateTime startDate = new DateTime(year, month, 1);
    int totalDays = startDate.AddMonths(1).Subtract(startDate).Days;

    int answer = Enumerable.Range(1, totalDays)
        .Select(item => new DateTime(year, month, item))
        .Where(date => date.DayOfWeek == dayOfWeek)
        .Count();

    return answer;
}

int numberOfThursdays = NumberOfParticularDaysInMonth(2010, 9, DayOfWeek.Thursday);
Comment

PREVIOUS NEXT
Code Example
Csharp :: replace filename extension c# 
Csharp :: unity update not called 
Csharp :: c# Showing a hidden WPF window 
Csharp :: aps.net core mvc chek box 
Csharp :: C# Search in JSON without deserialization 
Csharp :: how to change something in the window using a thread wpf 
Csharp :: hur delar man upp en e post på string c# 
Csharp :: principalcontext c# example 
Csharp :: how to reference a local file c# 
Csharp :: c# convert float to string 
Csharp :: read text c# 
Csharp :: how to create an initialized jtoken c# 
Csharp :: blazor navlink change bg of current component 
Csharp :: Expression And Filter 
Csharp :: 1180 - Lowest Number and Position C# 
Csharp :: linked list follow what in c# 
Csharp :: get c directory contains system windows c# 
Csharp :: what error code i should return in asp.net core whether user name or password are incorrect 
Csharp :: call Textboxfor in cs 
Csharp :: get the next letter after specific character in c# 
Csharp :: Appending to an Existing CSV File with csvhelper 
Csharp :: CefSharp.Core in clickones application 
Csharp :: C# walk down a tree and back 
Csharp :: unitydont play sound until finsihed 
Csharp :: open and close autocad api 
Csharp :: c# open explorer and select file 
Csharp :: sterge element din coada c# 
Csharp :: c# access control from another thread 
Csharp :: permutation and combination program in c# 
Csharp :: check if app have administrator rights c# 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =