日期:2014-05-17 浏览次数:20971 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace 红相表测试
{
public partial class Form1 : Form
{
public Socket client = null;
public string str;
public Thread t1;
bool flag = false;
public string StringToHex(string str)
{
//str = str.Trim();
byte[] ByteFoo = System.Text.Encoding.Default.GetBytes(str);
string TempStr = "";
foreach (byte b in ByteFoo)
{
if (b <= 16) //16进制显示时加个0
{
TempStr += "0"+b.ToString("X") + " "; //X表示十六进制显示
}
else
TempStr += b.ToString("X") + " "; //X表示十六进制显示
}
return TempStr;