Monday, February 15, 2010

Common .NET Snippets

I'll be adding to this / adding as I stumble across things I find myself looking up repeatedly...

Run code on the 'main' thread from a background thread (assuming your context is a WinForm)...


BeginInvoke((MethodInvoker)delegate {
// put code here
});


Show Guid as a 32 byte hex encoded string


Guid.NewGuid().ToString("B");


Date formatting


// returns something like "2010/02/15 11:05:23 PM"
DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss tt");

5 comments:

Anonymous said...

It`s really nice article. Thank u a lot

Kavya Sharma said...

Its good to be here, very nice post, the content is amazing, keep posting friend it will be very helpful for everyone, Thanks for sharing. I really liked it. We can assist you on your household shifting. Shifting home to a new place is considered as a hectic and tedious task. @ Packers And Movers Patna
http://packersmoverspatna.in/packers-and-movers-kanhaipur-patna

lernen said...

Ich brauche mehr Infos

generator equeipment said...

nice post .

my blog said...

so nice blog .