System.BitConverter.GetBytes C# (CSharp) Метод

GetBytes() публичный статический Метод

public static GetBytes ( bool value ) : byte[]
value bool
Результат byte[]
        public static byte[] GetBytes(bool value) {
            byte[] r = new byte[1];
            r[0] = (value ? (byte)Boolean.True : (byte)Boolean.False );
            return r;
        }
    

Same methods

BitConverter::GetBytes ( char value ) : byte[]
BitConverter::GetBytes ( double value ) : byte[]
BitConverter::GetBytes ( float value ) : byte[]
BitConverter::GetBytes ( int value ) : byte[]
BitConverter::GetBytes ( long value ) : byte[]
BitConverter::GetBytes ( short value ) : byte[]
BitConverter::GetBytes ( uint value ) : byte[]
BitConverter::GetBytes ( ulong value ) : byte[]
BitConverter::GetBytes ( ushort value ) : byte[]

Usage Example

Пример #1
0
        public void Update(Session session, JET_DBID dbid, Action <string> output)
        {
            using (var table = new Table(session, dbid, "indexes_stats", OpenTableGrbit.None))
            {
                byte[]       defaultValue = BitConverter.GetBytes(1);
                JET_COLUMNID columnid;
                Api.JetAddColumn(session, table, "priority", new JET_COLUMNDEF
                {
                    coltyp = JET_coltyp.Long,
                    grbit  = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL
                }, defaultValue, defaultValue.Length, out columnid);

                defaultValue = BitConverter.GetBytes(0);
                Api.JetAddColumn(session, table, "created_timestamp", new JET_COLUMNDEF
                {
                    cbMax  = 8, //64 bits
                    coltyp = JET_coltyp.Binary,
                    grbit  = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL
                }, defaultValue, defaultValue.Length, out columnid);

                Api.JetAddColumn(session, table, "last_indexing_time", new JET_COLUMNDEF
                {
                    cbMax  = 8,                    //64 bits
                    coltyp = JET_coltyp.Binary,
                    grbit  = ColumndefGrbit.ColumnFixed | ColumndefGrbit.ColumnNotNULL
                }, defaultValue, defaultValue.Length, out columnid);
            }

            SchemaCreator.UpdateVersion(session, dbid, "4.6");
        }
All Usage Examples Of System.BitConverter::GetBytes