本文整理汇总了C#中System.Collections.BitArray.ToByte方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.ToByte方法的具体用法?C# BitArray.ToByte怎么用?C# BitArray.ToByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.BitArray
的用法示例。
在下文中一共展示了BitArray.ToByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToFile
public void ToFile(string Path)
{
RijndaelManaged Rijndael = new RijndaelManaged();
Stream stream = new FileStream(Path, FileMode.Create);
using (stream)
{
using (CryptoStream cryptoStream = new CryptoStream(stream, Rijndael.CreateEncryptor(new UnicodeEncoding().GetBytes("h3y_gUyZ"), new UnicodeEncoding().GetBytes("h3y_gUyZ")), CryptoStreamMode.Write))
{
using (BinaryWriter Writer = new BinaryWriter(cryptoStream))
{
Writer.Write(Release);
Writer.Write(27981915666277746uL | (ulong)((byte)3) << 56);
Writer.Write(Revision);
Writer.Write((ulong)((long)(IsFavorite ? 1 : 0 & 1)));
Writer.Write(Name);
Writer.Write(Difficulty);
Writer.Write(PlayTime.Ticks);
Writer.Write(Hair);
Writer.Write(HairDye);
BitArray bb = new BitArray(new bool[] { false, false, false, false, false, false, false, false });
for (int i = 0; i < 8; i++)
{
bb[i] = HideVisual[i];
}
Writer.Write(bb.ToByte());
bb = new BitArray(new bool[] { false, false, false, false, false, false, false, false });
for (int j = 0; j < 2; j++)
{
bb[j] = HideVisual[j + 8];
}
Writer.Write(bb.ToByte());
Writer.Write(HideMisc);
Writer.Write((byte)SkinVariant);
Writer.Write(Life);
Writer.Write(MaxLife);
Writer.Write(Mana);
Writer.Write(MaxMana);
Writer.Write(ExtraAccessory);
Writer.Write(TaxMoney);
Writer.Write(HairColor.R);
Writer.Write(HairColor.G);
Writer.Write(HairColor.B);
Writer.Write(SkinColor.R);
Writer.Write(SkinColor.G);
Writer.Write(SkinColor.B);
Writer.Write(EyeColor.R);
Writer.Write(EyeColor.G);
Writer.Write(EyeColor.B);
Writer.Write(ShirtColor.R);
Writer.Write(ShirtColor.G);
Writer.Write(ShirtColor.B);
Writer.Write(UnderShirtColor.R);
Writer.Write(UnderShirtColor.G);
Writer.Write(UnderShirtColor.B);
Writer.Write(PantsColor.R);
Writer.Write(PantsColor.G);
Writer.Write(PantsColor.B);
Writer.Write(ShoeColor.R);
Writer.Write(ShoeColor.G);
Writer.Write(ShoeColor.B);
//Might have to write count = 1 for empty slots
for (int k = 0; k < Armor.Length; k++)
{
Writer.Write(Armor[k].ID);
Writer.Write(Armor[k].Prefix);
}
for (int l = 0; l < Dye.Length; l++)
{
Writer.Write(Dye[l].ID);
Writer.Write(Dye[l].Prefix);
}
for (int m = 0; m < 58; m++)
{
Writer.Write(Inventory[m].ID);
Writer.Write(Inventory[m].Count);
Writer.Write(Inventory[m].Prefix);
//Favorited
Writer.Write(false);
}
for (int n = 0; n < MiscEquips.Length; n++)
{
Writer.Write(MiscEquips[n].ID);
Writer.Write(MiscEquips[n].Prefix);
Writer.Write(MiscDye[n].ID);
Writer.Write(MiscDye[n].Prefix);
}
for (int num = 0; num < 40; num++)
{
Writer.Write(Bank[num].ID);
Writer.Write(Bank[num].Count);
Writer.Write(Bank[num].Prefix);
}
//.........这里部分代码省略.........
示例2: GetLedState
internal byte GetLedState()
{
var ledStateBits = new BitArray (
new []{
FinalRedLedState,
FinalGreenLedState,
UpdateRedLedState,
UpdateGreenLedState,
InitialRedLedBlinkingState,
InitialGreenLedBlinkingState,
RedBlinking,
GreenBlinking}
);
return ledStateBits.ToByte();
}