c# - TimeSpan not working -


heres code have re arranged, still have same problem, not able find start , end times on last page? how do this?

public void start()     {         datetime starttime = datetime.now;     }      protected void btnstart_click(object sender, eventargs e)     {         start();         response.redirect("~/end.aspx");     } 

public void end()     {         datetime endtime = datetime.now;     }     protected void btnend_click(object sender, eventargs e)     {         end();         response.redirect("~/display.aspx");     } 

public partial class display : system.web.ui.page {     protected void page_load(object sender, eventargs e)     {         timespan timespent = endtime - starttime;          lbldisplay.text = string.format("time: {0}", timespent);     } } 

now can me on this?

you not need convert string.

datetime start = datetime.now; datetime end = datetime.now; 

(note: 2 times above identical)

once have done that, can use 1 of other techniques shown above timespan:

var timespent = (end - start); 

or

timespan timespent = end.subtract(start); 

to display it:

console.writeline(timespent.totalmilliseconds); 

now, go code! :)


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -