Q:

Write a program in C# Sharp to compute what day was yesterday

0

Write a program in C# Sharp to compute what day was yesterday.

Expected Output :

Today is : 17/09/2016
 The Yesterday was : 16/09/2016

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;

class dttimeex44
{
    static void Main()
    {
	Console.Write("\n\n Compute what day was  Yesterday :\n");
	Console.Write("--------------------------------------\n");
	Console.WriteLine(" Today is : {0}", DateTime.Today.ToString("dd/MM/yyyy"));
	DateTime yd = GetYesterday();
	Console.WriteLine(" The Yesterday was : {0} \n", yd.ToString("dd/MM/yyyy"));
    }
    static DateTime GetYesterday()
    {
	return DateTime.Today.AddDays(-1);
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now