当前位置: 首页>>代码示例>>C#>>正文


C# BitArray.ToByte方法代码示例

本文整理汇总了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);
                        }
//.........这里部分代码省略.........
开发者ID:pema99,项目名称:TerrariaInventoryEditor,代码行数:101,代码来源:Player.cs

示例2: GetLedState

        internal byte GetLedState()
        {
            var ledStateBits = new BitArray (
                new []{
                    FinalRedLedState,
                    FinalGreenLedState,
                    UpdateRedLedState,
                    UpdateGreenLedState,
                    InitialRedLedBlinkingState,
                    InitialGreenLedBlinkingState,
                    RedBlinking,
                    GreenBlinking}
            );

            return ledStateBits.ToByte();
        }
开发者ID:Patapum,项目名称:Lando,代码行数:16,代码来源:LedBuzzerStatus.cs


注:本文中的System.Collections.BitArray.ToByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。