I want to determinate if there no symbol in a string?
for example
"12ab34", "123a5bc", "a123c4" is ok, but "23#45", 2a,35" is not ok.
You could use regular expressions...
Here some code demonstrating the IsValidString() function that checks your
requirements for your strings.
-----------------------------------------------
using System.Text.RegularExpressions;
private void button1_Click( object sender, EventArgs e )
{
CheckStrings();
}
static private void CheckStrings()
{
StringBuilder sb = new StringBuilder();
string[] arr = new string[]
{ "12ab34", "123a5bc", "a123c4", "23#45", "2a,35" };
foreach ( string s in arr )
{
sb.Append( s );
sb.Append( " is " );
sb.Append( IsValidString( s ) ? "OK" : "not OK" );
sb.Append( "\n" );
}
MessageBox.Show( sb.ToString() );
}
static private bool IsValidString( string s )
{
Regex re = new Regex( "^[0-9a-zA-Z]*$" );
return re.IsMatch( s );
}