What does DateTime now = DateTime.Now; do in C#? -


i found out how current date , time variables (right?) in c# this thread code

datetime = datetime.now; string date = now.getdatetimeformats('d')[0]; string time = now.getdatetimeformats('t')[0]; 

however i'm not sure first line does. after thinking suppose calls current date , time data computer , applies/tells program.

by way, i'm noob @ programming , new c#.

the first line

datetime = datetime.now; 

takes current time, , stores in variable. reason it's done make sure subsequent calls of getdatetimeformats performed on variable representing same time. if call datetime.now several times, may different time each time make call.

for example, if

string date = datetime.now.getdatetimeformats('d')[0]; string time = datetime.now.getdatetimeformats('t')[0]; 

very close midnight, date , time portions may belong different dates.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -