|
|
|
start date: Thu, 23 Aug 2007 08:14:06 -0700,
posted on: microsoft.public.dotnet.languages.csharp
back
| Thread Index |
|
1
Dave
|
|
2
Nicholas Paldino [.NET/C# MVP]
|
|
3
Ignacio Machin \( .NET/ C# MVP \) machin TA laceupsolutions.com
|
Conver byte to string of 1's and 0's
I receive input in a byte which gives a value of 0-255. Is there an easy way
to convert this to a string. The string constiting of 1's and 0's. This is
necessay because I'm looking for a certain pattern of 12 1's and 0's in a
sting of 300 bits long. The pattern can be anywhere and doesn't start at
every fourth bit or any particular position.
Date:Thu, 23 Aug 2007 08:14:06 -0700
Author:
|
Re: Conver byte to string of 1's and 0's
Dave,
You can call the static ToString method on the Convert class, passing
the byte, and 2 as the toBase parameter, and it will give you the byte in
base-2 representation.
Of course, if you are looking for a specific pattern, you could just use
a bitmask, and perform shift operations, applying the bitmask every step of
the way.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Dave" wrote in message
news:2DFC236C-82B5-49E2-B8D3-390A95933F67@microsoft.com...
>I receive input in a byte which gives a value of 0-255. Is there an easy
>way
> to convert this to a string. The string constiting of 1's and 0's. This is
> necessay because I'm looking for a certain pattern of 12 1's and 0's in a
> sting of 300 bits long. The pattern can be anywhere and doesn't start at
> every fourth bit or any particular position.
Date:Thu, 23 Aug 2007 11:26:35 -0400
Author:
|
Re: Conver byte to string of 1's and 0's
Hi,
In the worst case escenario this is extremely simple to do.
Of course, you have Convert.ToString( byte, int) :)
"Dave" wrote in message
news:2DFC236C-82B5-49E2-B8D3-390A95933F67@microsoft.com...
>I receive input in a byte which gives a value of 0-255. Is there an easy
>way
> to convert this to a string. The string constiting of 1's and 0's. This is
> necessay because I'm looking for a certain pattern of 12 1's and 0's in a
> sting of 300 bits long. The pattern can be anywhere and doesn't start at
> every fourth bit or any particular position.
Date:Thu, 23 Aug 2007 11:23:08 -0400
Author:
|
|
|