C#位操作未按预期工作

C#位操作未按预期工作,c#,C#,下面给出了一个C#程序示例 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your c

下面给出了一个C#程序示例

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //Your code goes here

            byte prot = 1;
            byte media = 3;
            byte type = 7;
            var ProtoMediaType = (byte)(((int)proto << 6) | ((int)media << 6) | ((int)type));
            //m_ProtocolMediaType = 0;
            Console.WriteLine(m_ProtocolMediaType);

        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text.RegularExpressions;
名称空间测试仪
{
公共课程
{
公共静态void Main(字符串[]args)
{
//你的密码在这里
字节prot=1;
字节媒体=3;
字节类型=7;

var ProtoMediaType=(byte)((int)proto1您提供的代码无法编译。请提供一个实际的。但是,一旦明显的缺陷得到修复,
(1)(您应该检查您的“信封背面”计算是如何工作的,因为我猜它不会将
媒体
移动6位…)@JonSkeet-你说得对。我正在通过
4
移动媒体,这也是我在代码中应该做的。我应该将
proto
移动7