And the answer shall come...this is it. This is why I love the hell out of .NET. I tell this to my students when I teach .NET, but each day I use the Framework I start to live it even more. Sure, there are things you fight with, there are things you hate, but really when it comes down to it: A LOT of good thought was put into the Framework. There are Utility Classes galore. (Of course, there's no HashMap, but that's another day)
What I did in a cheesy moment (a 3am moment) of frustration:
public unsafe static byte[] UIntToBytes(uint UIntIn){ //turn a uint32 into 4 bytes byte[] fourBytes = new byte[4]; uint* pt = &UIntIn; byte* bt = (byte*)&pt[0]; fourBytes[0] = *bt++; fourBytes[1] = *bt++; fourBytes[2] = *bt++; fourBytes[3] = *bt++; return fourBytes;}
Here's what it looks like now (in VB.NET):
Public
I can't believe I stooped to writing unsafe :) code to do something as simple as getting the Bytes out of an Integer. Fool me once, shame on you. Fool me twice, shame on me.
Scott at DevReach in Bulgaria in October
Developer Stand up Comedy - Coding 4 Fun
TechDays/DevDays Netherlands and Belgium:
Posts by Category Posts by Month
Greatest Hits Dev Tools List