如何在C#中声明和设置位变量的值? [英] How to declare and set value for a bit variable in C# ?

查看:271
本文介绍了如何在C#中声明和设置位变量的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#在Windows Media Http流协议(WMSP)中构建流视频服务器.我已经阅读了WMSP规范.在数据包的帧标题为$ H中,$ D ...具有2个字段:

B(1位):1位标志.如果该包发送后立即发送下一个包,则该标志应设置为1.在本文中,立即"是指服务器在两个数据包的传输之间不故意引入延迟(例如调步延迟).在所有其他情况下,标记必须为0.< 56>

帧(7位):7位字段.该字段的值必须为0x24. (如果将B和Frame字段视为一个字节,则当B字段为0时此字节的值将为0x24,而当B字段为1时此字节的值将为0xA4.)

当C#中最小的数据类型为byte时,此2字段的数据类型为bit.那么,如何声明和设置这2个字段的值呢?

I''m buiding a streaming video server in Windows Media Http Streaming Protocol (WMSP) with C#. I''ve read WMSP Specification. In Framing Header of packets as $H, $D... has 2 fields :

B (1 bit): A 1-bit flag. This flag SHOULD be set to 1 if the next packet will be sent immediately after this packet is sent. In this context, "immediately" means that the server does not intentionally introduce a delay (such as a pacing delay) between the transmission of the two packets. In all other cases, the flag MUST be 0.<56>

Frame (7 bits): A 7-bit field. This field MUST have the value 0x24. (If the B and Frame fields are treated as a single byte, the value of this byte will be 0x24 when the B field is 0, and 0xA4 when the B field is 1.)

Data type of this 2 field is bit when the smallest data type in C# is byte. So, how to declare and set value for this 2 field ?

推荐答案

H,


D ...有2个字段:

B(1位):1位标志.如果该包发送后立即发送下一个包,则该标志应设置为1.在本文中,立即"是指服务器在两个数据包的传输之间不故意引入延迟(例如调步延迟).在所有其他情况下,标记必须为0.< 56>

帧(7位):7位字段.该字段的值必须为0x24. (如果将B和Frame字段视为一个字节,则当B字段为0时此字节的值为0x24,而当B字段为1时此字节的值为0xA4.)

当C#中最小的数据类型为byte时,此2字段的数据类型为bit.因此,如何声明和设置这2个字段的值?
D... has 2 fields :

B (1 bit): A 1-bit flag. This flag SHOULD be set to 1 if the next packet will be sent immediately after this packet is sent. In this context, "immediately" means that the server does not intentionally introduce a delay (such as a pacing delay) between the transmission of the two packets. In all other cases, the flag MUST be 0.<56>

Frame (7 bits): A 7-bit field. This field MUST have the value 0x24. (If the B and Frame fields are treated as a single byte, the value of this byte will be 0x24 when the B field is 0, and 0xA4 when the B field is 1.)

Data type of this 2 field is bit when the smallest data type in C# is byte. So, how to declare and set value for this 2 field ?


[ ^ ]涵盖我能想到的每个答案.
This[^] covers every answer I can think of.


这篇关于如何在C#中声明和设置位变量的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆