标题:很强大的代码。可是不知道怎么时候。谁帮我弄弄
只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-229379-1-1.html




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

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