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
Post a Comment