We usually fall into the situation where conversion of Timespan to DateTime is required.
Here is how it can be done easily just by casting:
Suppose we have two variables DateTime and Timespan and Timespan one with some value
DateTime dt;
TimeSpan ts="XXX";
We can covnert 'ts' to 'dt' like this:
dt= Convert.ToDateTime(ts.ToString());
Thats it!!!
Hope you have liked the solution.
Varun
5 comments:
very nice
thanks
Hey its very short and sweet solution.
Thanks a lot
perfect, thank you very much
Nice but does not work when TS includes days, e.g. TimeSpan(2, 1, 30, 10);
Thanks.. Neat and Clean solution..
Post a Comment