日期:2014-05-18 浏览次数:20926 次
int i = 124344343; byte[] bs = new byte[sizeof(int)]; bs = BitConverter.GetBytes(i); foreach (char c in bs) { MessageBox.Show(Convert.ToString(c)); }
------解决方案--------------------
public string test(int flag) { if (flag >= 0 && flag <= 255) { System.Text.ASCIIEncoding ascEn = new System.Text.ASCIIEncoding(); byte[] arr = new byte[] { (byte)flag }; string str = ascEn.GetString(arr); return (str); } else { return null; } }
------解决方案--------------------
decimal dm = 909391681; byte[] by = BitConverter.GetBytes(decimal.ToInt64(dm)); string acs = Encoding.ASCII.GetString(by);//貌似多了几个\0