首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#中一些小技能

2013-07-04 
C#中一些小技巧/// summary/// 一个永远不会获得焦点的button/// /summary[Serializable]public class

C#中一些小技巧
/// <summary>
    /// 一个永远不会获得焦点的button
    /// </summary>
    [Serializable]
    public class SpeedButton : Button
    {
        public CMBSpeedButton()
            : base()
        {
            base.SetStyle(ControlStyles.Selectable, false);
        }
    }


//字节与16进制数转换
class Util
    {
        public static byte uniteBytes(byte b1,byte b2)//将两个字节合并成一个16进制数
        {
            byte retByte=new byte();
            string s=Encoding.UTF8.GetString(new byte[]{b1,b2});
            retByte = Convert.ToByte("0x"+s, 16);
            return retByte;
        }

        public static  string BytesToHexString(byte[] b)
        {
            //byte[] b = encode.GetBytes(s);//按照指定编码将string编程字节数组
            string result = string.Empty;
            for (int i = 0; i < b.Length; i++)//逐字节变为16进制字符
            {
                result +=Convert.ToString(b[i], 16);
            }
            return result;
        }
    }

热点排行