Bug in BitConverter.ToString(byte[])

  • Thread starter Thread starter Jon Skeet [C# MVP]
  • Start date Start date
J

Jon Skeet [C# MVP]

Something that I haven't found referenced anywhere else, and which
might bite someone else (it bit me when unit-testing an MD5 hash
implementation):

byte[] tmp = {0,1,2,3,4};
string bug = BitConverter.ToString(tmp);

bug will be "00-1-2-3-4" rather than "00-01-02-03-04" as it is in the
normal framework.

Admittedly I've only tested on the Pocket PC 2002 and 2003 emulators...
 
This has been fixed in SP2.

David Wrighton
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Chris Tacke, eMVP" <[email protected]>
| References: <[email protected]>
| Subject: Re: Bug in BitConverter.ToString(byte[])
| Date: Wed, 4 Feb 2004 09:49:18 -0500
| Lines: 32
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: nat2.applieddata.net 64.72.200.61
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:44845
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| I can confirm that - I've seen the same on vanilla CE 4.1.
|
| --
| Chris Tacke, eMVP
| Co-Founder and Advisory Board Member
| www.OpenNETCF.org
| ---
| Windows CE Product Manager
| Applied Data Systems
| www.applieddata.net
|
|
| | > Something that I haven't found referenced anywhere else, and which
| > might bite someone else (it bit me when unit-testing an MD5 hash
| > implementation):
| >
| > byte[] tmp = {0,1,2,3,4};
| > string bug = BitConverter.ToString(tmp);
| >
| > bug will be "00-1-2-3-4" rather than "00-01-02-03-04" as it is in the
| > normal framework.
| >
| > Admittedly I've only tested on the Pocket PC 2002 and 2003 emulators...
| >
| > --
| > Jon Skeet - <[email protected]>
| > http://www.pobox.com/~skeet
| > If replying to the group, please do not mail me too
|
|
|
 
David Wrighton said:
This has been fixed in SP2.

That's good to know. I haven't yet got to grips with how SP2 works in
terms of emulators - do I just install it on my laptop and the right
thing happens?
 
Nope. the SP install simply gives you the SPs. You can replace those in
the Studio directory with the new ones and then Studio will push the SP
binaries over during debugging.

-Chris
 
Nope. the SP install simply gives you the SPs. You can replace those in
the Studio directory with the new ones and then Studio will push the SP
binaries over during debugging.

Ah, right. That's fine - so long as there *is* a way of working with
the SPs in the emulators. Do new PocketPC 2003 devices come with SP2,
or do we also need to include it in our installers?
 
Back
Top