string str = "今天是个好天气,我今天被老师批评了一顿,Echo,是个好同学";
Console.WriteLine(str.Contains("Echo"));
Console.WriteLine(str.EndsWith("Echo"));
Console.WriteLine(str.StartsWith("今天"));
Console.WriteLine(str.IndexOf("个"));
Console.WriteLine(str.Insert(3, "晴天真是"));
Console.WriteLine(str.LastIndexOf("个"));
Console.WriteLine(str.Remove(3));
Console.WriteLine(str.Replace("Echo", "Echo_Lee"));
Console.ReadLine();
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3118072cbbda0ba105a0e63725657eb2.png)
string str_BSTATUS1 = Convert.ToString((Convert.ToByte(PassData.ReceiveBuffer[7])), 2);
str_BSTATUS1 = str_BSTATUS1.Insert(0, new string('0', 8 - str_BSTATUS1.Length));
char[] Password = new char[6];
int[] PasswordBuffer = new int[6];
for (int i = 0; i < str.Length; i++)
{
Password[i] = Convert.ToChar(str.Substring(i, 1).Trim());
}
byte[] Data = Encoding.GetEncoding("GB2312").GetBytes(Password);
for (int i = 0; i < 6; i++)
{
PasswordBuffer[i] = Convert.ToInt16(Data[i]);
}
frmSerialport.Upgrade(PasswordBuffer);
labFWVersion.Text = System.Text.Encoding.ASCII.GetString(FWVersion);
labSWVersion.Text = System.Text.Encoding.ASCII.GetString(SWVersion);