In the text message Platform project, a command word is used to retrieve the information sent from the mobile phone, that is, the character string starts from the first digit to the letter, and the character is not the end of the letter.
It mainly depends on the ASCII of the letter. If the first occurrence is not within the ASCII range of the letter, it will jump out. The following code is available:
Code
Private void button#click (object sender, EventArgs e)
{
MessageBox. Show (GetCommandCode (this. textBox1.Text. Trim ()));
}
Private string GetCommandCode (string input)
{
String str = string. Empty;
CharEnumerator CEnumerator = input. GetEnumerator ();
While (CEnumerator. MoveNext ())
{
Byte [] array = new byte [1];
Array = System. Text. Encoding. ASCII. GetBytes (CEnumerator. Current. ToString ());
Int asciicode = (short) (array [0]);
If (asciicode> = 97 & asciicode <= 122) | (asciicode> = 65 & asciicode <= 90 ))
{
Str + = CEnumerator. Current. ToString ();
}
Else
Break;
}
Return str;
}