c# - How can I convert it to DateTime without adding a new variable? -


i'm new in c#.so have pretty simple question. have string value.how can convert datetime without adding new variable? here code:

string start_date = datetime.now.tostring("mm.dd.yyyy"); startdate.text = start_date;  datetime start_date = convert.todatetime(start_date);  start_date = start_date.adddays(1); startdate.text = convert.tostring(start_date); 

i convert start_date start_date without adding variables. in convert.todatetime(start_date) command can use startdate.text instead of start_date....

conceptually, can't. can avoid giving variable name, won't function differently if decide give name.

omitting name, in case, simple not declaring identifier, , using initialized value anywhere have used identifier:

startdate.text = convert.todatetime(start_date).adddays(1).tostring(); 

note here variable still going exist behind scenes, it's not given name , isn't accessible after end of expression.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -