This should work:
byte ConvertToByte(BitArray bits)
{
if (bits.Count != 8)
{
throw new ArgumentException("bits");
}
byte[] bytes = new byte[1];
bits.CopyTo(bytes, 0);
return bytes[0];
}
More Related Contents:
- How can I convert BitArray to single int?
- Why is a Dictionary “not ordered”?
- Why do BCL Collections use struct enumerators, not classes?
- Why is there no Char.Empty like String.Empty?
- Is it possible to do .NET binary serialization of an object when you don’t have the source code of the class?
- What is C# analog of C++ std::pair?
- Convert binary string into integer
- How to create multiple directories from a single full path in C#?
- BitArray – Shift bits
- Will #if RELEASE work like #if DEBUG does in C#?
- How to add extension methods to Enums
- AddIdentity vs AddIdentityCore
- Execution order of conditions in C# If statement
- Best way to limit the number of active Tasks running via the Parallel Task Library
- How can I determine browser window size on server side C#
- Normalize newlines in C#
- Getting the location from a WebClient on a HTTP 302 Redirect?
- How do I get a Video Thumbnail in .Net?
- Operator “>” cannot be applied to type ‘ulong’ and ‘int’
- Active solution platform VS Project Platform VS Platform target
- ProgressBar is slow in Windows Forms
- What is a “Nested Quantifier” and why is it causing my regex to fail?
- Sending email through gmail SMTP on GoDaddy [closed]
- .NET: Why is TryParseExact failing on Hmm and Hmmss?
- Rename JProperty in json.net
- How to write to the main exe’s .config userSettings section?
- Is there a .NET way to enumerate all available network printers?
- Marshal.PtrToStructure (and back again) and generic solution for endianness swapping
- A call to SSPI failed, see inner exception – The Local Security Authority cannot be contacted
- How to get the current user’s Active Directory details in C#