My online tech scrapbook where I keep my notes in case I need to look them up later
Friday, March 22, 2013
C# Iterate Dictionary
Using "foreach" and "KeyValuePair" as the element. Refer to this: http://stackoverflow.com/questions/141088/what-is-the-best-way-to-iterate-over-a-dictionary-in-c
Monday, March 18, 2013
C# Start New Process
This is how it's done:http://stackoverflow.com/questions/258416/shellexecute-equivalent-in-net
If you need to start multiple processes asynchronously, you'd need to first start multiple threads and then within each thread, each process is started.
Reference for this: http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C
How to add arguments: http://msdn.microsoft.com/en-sg/library/system.diagnostics.processstartinfo.arguments.aspx
If you need to start multiple processes asynchronously, you'd need to first start multiple threads and then within each thread, each process is started.
Reference for this: http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C
How to add arguments: http://msdn.microsoft.com/en-sg/library/system.diagnostics.processstartinfo.arguments.aspx
Tuesday, March 12, 2013
C# Getting Time Since Epoch
Many things are simpler in C# than e.g. in Java, but getting the Epoch time is an exception, and this is how it's done.
TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1); double currentTime = timeSpan.TotalSeconds; |
Subscribe to:
Posts (Atom)