When you get the length of numbers or letters in a string in your program, you can iterate through each character in the string using the MoveNext method of the Charenumerator object. The characters are encoded using the ASCII-encoded GetBytes method in the System.Text.Encoding class, and then determine whether the ASCII value of the encoded character is between the specified values and, if so, add it to an array, and finally the number of items in the array is obtained. The key code to get the number or letter length in a string is as follows:
ArrayList itemList = new ArrayList ();
Charenumerator CEnumerator = TextBox1.Text.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 >= && asciicode <= 57) | | (Asciicode >= && asciicode <= 90) | | (Asciicode >= && asciicode <= 122))
{
Itemlist.add (CEnumerator.Current.ToString ());
}
TextBox2.Text = ItemList.Count.ToString ();
}