Finally, BitConverter for .NETMF

I was scanning the code changes for 4.3 QFE 1 and I was really happy to see they have included a native Implementation of BitConverter.

Old news I am sure, but I had not been doing much NETMF lately so this was a nice surprise.

1 Like

I read a work item on codplex that one (or some) BitConverter methods have a memory leak :frowning:

@ taylorza - Considering the nature of the limited resources on embedded devices, BitConverter is critically important. Having said that, I am not using these built-in bit converter classes because mine are better (I have my own 4.3 Firmware). The classic methods (from standard .NET) are VERY limited. I started with BitConverter-like methods, I even used some of the methods from the TinyFileSystem. But, if you use them A LOT, you’ll realize, these methods suck. I made mine extension methods for easy calling. I also added additional parameters with defaults to pass in byte arrays of any size and a start index that defaults to 0. That way the original method still works, but it also allows you to read a single integer out of a long byte array without creating a new byte array and wasting memory and cluttering your code. Also, I have an Endian flag parameter with a default value. These overloads and changes clean up the code and reduce the memory used.

Anyway, when a BitConverter class finally showed up, I was a bit disappointed in how basic it was. This class is so important that .NET MF should be leading the entire framework here. Now that .NET is open source, maybe this should be proposed as a change to all of .NET.

I should post my methods to codeshare at some point.

*One caveat: I claim that my methods are “better”, but they probably perform worse than the native code-based methods.

1 Like

I believe only the compilers are open source, not the framework itself?

You have the complete netmf framework source code at
if you want to compile you own release.

It is unfortunate that they have not done a good job exposing BitConverter, it is such a core aspect of embedded development. I almost always find myself needing this functionality.

Yup, me too. That’s my wish #2 for 4.4…