harish reddy

harish reddy

  • NA
  • 162
  • 33.8k

Datetime and day of week

Mar 8 2018 9:54 PM
Write a program, which prints, on the console which day of the week is today
 
 1. //DayOfWeek now = DateTime.Today.DayOfWeek;
//Console.WriteLine(now);
2. DateTime today = DateTime.Today;
string date=today.DayOfWeek;
Console.WriteLine(today);
 
Questions are : 
 
A) With the first code i am getting the value....but with the second i am not getting. I want to know how we can do from 2nd one...
 
B) Also we have DATETIME and DAYOFWEEK. which one should we use while using IDE?
 
C) Also i get confused should we use brackets at the end or not ? in what cases should we use brackets .
For example if i give DayOfWeek now = DateTime.Today.DayOfWeek(); it gives me error.
But if i give DayOfWeek now = DateTime.Today.DayOfWeek; it works. What is the concept here? Pls suggest 

Answers (2)