 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to display the previous day
To display the previous day, use the AddDays() method and a value -1 to get the previous day.
Firstly, use the following to get the current day −
DateTime.Today
Now, add -1 to the AddDays() method to get the previous day −
DateTime.Today.AddDays(-1)
The following is the code −
Example
using System; using System.Collections.Generic; using System.Linq; public class Demo {    public static void Main() {       Console.WriteLine("Today = {0}", DateTime.Today);       Console.WriteLine("Previous Day = {0}", DateTime.Today.AddDays(-1));    } }  Output
Today = 9/4/2018 12:00:00 AM Previous Day = 9/3/2018 12:00:00 AM
Advertisements
 