1

I am trying to adjust hijri date by adding one or two days to current date as in normal gregorian date but seems to be different in C#, this is my code giving me an error:

string does not contain a definition for AddDays.

var HijriDate = DateTime.Now.ToString("dddd dd MMMM yyyy", new CultureInfo("ar-SA"));
var NewHijriDate = HijriDate.AddDays(1);
Labelhijridate.Text = NewHijriDate;
Muhammad Sulaiman
  • 2,399
  • 4
  • 14
  • 28
  • of course, it will not work because the type of HijriDate is a string and not DateTime [link](https://stackoverflow.com/a/13797790/13124794) **see here** – odaiwa Oct 01 '22 at 14:34

1 Answers1

4

You're calling .ToString early.. Do DateTime operations before calling .ToString

var HijriDate = DateTime.Now;
var NewHijriDate = HijriDate.AddDays(1);
Labelhijridate.Text = NewHijriDate.ToString("dddd dd MMMM yyyy", new CultureInfo("ar-SA"));
Muhammad Sulaiman
  • 2,399
  • 4
  • 14
  • 28