1.byte[]转换为string
string RecStartFrameStr = System.Text.Encoding.Default.GetString(MainForm.readData);
2.string转换为byte[]
string strFileName;
byte[] byteFileName = Encoding.ASCII.GetBytes(strFileName);
3.int转换为byte[]
int PerFrameCnt = 0;
byte[] DataFrame = new byte[1029];
DataFrame[1] = (byte)PerFrameCnt;
DataFrame[2] = (byte)~PerFrameCnt; //取反
4.byte[]转int
byte[] k = {12,13,14};
int m = System.BitConverter.ToInt32(k,0);
5.int转string
int a = 2023;
string s1 = a.ToString(s);
string s2 = Convert.ToString(a);
6.string 转int
string s = "2023"
int a = int.Parse(s);
int b = 0;
int.TryParse(s, out b);
int c = Convert.ToInt32(s);
7.txtBattVol.Text转为double
string strBatVol = txtBattVol.Text;
double dlBatVol = double.Parse(strBatVol);
//第一种转换方法
double p1 = double.Parse(strBatVol );
//第二种转换方法
double p2= Convert.ToDouble(strBatVol );