| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 539 人关注过本帖
标题:很强大的代码。可是不知道怎么时候。谁帮我弄弄
取消只看楼主 加入收藏
xjxxdnmwj
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2008-5-12
收藏
 问题点数:0 回复次数:0 
很强大的代码。可是不知道怎么时候。谁帮我弄弄
public static object EndianFlip(object oObject)
        {
            string sFieldType;
            Type tyObject = oObject.GetType();
            FieldInfo[] miMembers;
            miMembers = tyObject.GetFields();
            for (int Looper = miMembers.GetLowerBound(0);
                   Looper <= miMembers.GetUpperBound(0);
                   Looper++)
            {
                sFieldType = miMembers[Looper].FieldType.FullName;
                if (((sFieldType, "System.UInt16", true) == 0))
                {
                    ushort tmpUShort;
                    tmpUShort = (ushort)miMembers[Looper].GetValue(oObject);
                    tmpUShort = (ushort)(((tmpUShort & 0x00ff) << 8) +
                          ((tmpUShort & 0xff00) >> 8));
                    miMembers[Looper].SetValue(oObject, tmpUShort);
                }
                else if ((sFieldType, "System.UInt32", true) == 0)
                {
                    uint tmpInt;
                    tmpInt = (uint)miMembers[Looper].GetValue(oObject);
                    tmpInt = (uint)(((tmpInt & 0x000000ff) << 24) +
                                      ((tmpInt & 0x0000ff00) << 8) +
                                      ((tmpInt & 0x00ff0000) >> 8) +
                                      ((tmpInt & 0xff000000) >> 24));
                    miMembers[Looper].SetValue(oObject, tmpInt);
                }
            }
            return (oObject);
        }
搜索更多相关主题的帖子: 代码 
2008-08-22 07:31
快速回复:很强大的代码。可是不知道怎么时候。谁帮我弄弄
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016225 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved