Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a code for 1000 lines.
I need to know how much time each block is causing.
So I used a string builder to store current Time.

C#
StringBuilder sb=new StringBuilder();



C#
sb.Append(DateTime.Now.ToString());


I am using the above code to node all the region which causes time.
Then I've written that to a Text document to Analyse.

That's not showing much differences.

I need to display time in microseconds.

Is there any way to display current time in Microseconds

C#
8/7/2014 5:15:13 :100 PM

C#
8/7/2014 5:15:13 :330 PM

C#
8/7/2014 5:15:13 :434 PM


I f I get the timing in Microseconds I can analyse the code properly.

How to solve this.
Posted
Comments
Yannick Brodard 7-Aug-14 8:30am    
You can use DateTime.Now.Millisecond and if you want to format the display of your date with milliseconds just do : String.Format("{0:dd/MM/yy HH:mm:ss.FFF}", myDateTime);
KUMAR619 7-Aug-14 9:15am    
Thanks Yannick Brodard.

C#
StringBuilder sb=new StringBuilder();
sb.Append(String.Format("{0:MM/dd/yyyy HH:mm:ss.FFF}", DateTime.Now));


This link can help : Custom Date and Time Format Strings
 
Share this answer
 
v2
It is very simple thing in c# coding. You just have to write below code.Where you want to display time in miliseconds..

C#
DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss :FFFFFFF tt");


For Example,
I have display that on my label.
C#
lblDate.Text =DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss :FFFFFFF tt");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900