Tag Archives: dates

Compare performance looping over DateTime and integer variables in C#

The example Find Friday the Thirteenths in C# doesn’t really worry about performance. It uses integers to loop over the dates within a range. For every year between the start and end dates, the code considers the 13th of each … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , , , , , , | Leave a comment

Find Friday the Thirteenths in C#

The following code shows how this example lists the Friday the Thirteenths between selected start and end dates. // List Friday the 13ths between the start and end dates. private void btnGo_Click(object sender, EventArgs e) { lstResults.Items.Clear(); // Get the … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , , , | 1 Comment

Look for dates in the digits of Pi in C#

The example Find patterns within pi in C# looks for patterns within the digits of Pi. You can use that example to look for dates such as 4/1. This example determines whether the first 100 thousand digits of Pi contains … Continue reading

Posted in algorithms, mathematics, strings | Tagged , , , , , , , , , , , , | Leave a comment

Find the Friday following a given date in C#

This example shows how you can find the Friday following a particular date. You can use a similar method to find other days of the week following a specific date. (Note that I have updated this example from its original … Continue reading

Posted in variables | Tagged , , , , , , , , , , , | 2 Comments

Find the days, hours, minutes, or seconds between two dates in C#

This example uses a TimeSpan to find the days, hours, minutes, or seconds between two dates. When the user changes the date text, the program executes the following code. // If the text is a date, display // the elapsed … Continue reading

Posted in parsing, variables | Tagged , , , , , , , , , , , , , | Leave a comment