tags:

views:

44

answers:

1
    Literal four = new Literal();
    string timeanddate;
    timeanddate = DateTime.UtcNow.ToString();
    DateTime dt = new DateTime();
    dt = Convert.ToDateTime(timeanddate);
    dt.AddHours(3);
    four.Text = "3hr added and this gives>>  " + dt.ToString();
    form1.Controls.Add(four);

it should add 3 to hrs but doesnot, its like the line addhours does not exist

please help

+4  A: 

The DateTime type is immutable.

Luckily, the solution is quite simple:

dt = dt.AddHours(3);
Dan Tao
thankyou. . . . .