Private void the button1_Click ( Object SENDER, EventArgs E) { // remove craniocaudal specified character string String MyInfo to = " - People's Republic of China - " ; // display the "People's Republic of China" MessageBox.Show (MyInfo.Trim ( new new char [ . 1 ] { ' - ' }), " information presentation " , MessageBoxButtons.OK, MessageBoxIcon.Information); MyInfo to = " - People's Republic of China -, - " ; // display the "People's Republic of China" MessageBox.Show (MyInfo.Trim ( new new char [ 2 ] { ' - ' , ' , ' }), " information presentation " , MessageBoxButtons.OK, MessageBoxIcon.Information); MyInfo to = " - People's Republic of China - " ; // display the "People's Republic of China -" MessageBox.Show (MyInfo.TrimStart ( new new char [ . 1 ] { ' - ' }), " information presentation ", MessageBoxButtons.OK, MessageBoxIcon.Information); MyInfo to = " - People's Republic of China -, - " ; // Display "People's Republic of China -, -" MessageBox.Show (MyInfo.TrimStart ( new new char [ 2 ] { ' - ' , ' , ' }), " information presentation " , MessageBoxButtons.OK, MessageBoxIcon.Information); MyInfo to = " - People's Republic of China - " ; // show' - People's Republic of China " MessageBox.Show (MyInfo.TrimEnd ( new new char [ . 1 ] { ' - ' }), " information presentation " , MessageBoxButtons.OK, MessageBoxIcon.Information); MyInfo to = " - People's Republic of China -, - " ; // Display "- People's Republic of China" MessageBox.Show (MyInfo.TrimEnd ( new new char [ 2 ] { ' - ' , ' , ' }), " information presentation ", MessageBoxButtons.OK, MessageBoxIcon.Information); }
Original: https: //www.cnblogs.com/Scholars/p/9162598.html