Aaron,
You could try something like this
string msg = " This is my message";
public class StringUtil
{
public StringUtil()
{
}
public bool IsValidWordLenght(string value, int maxLenght)
{
string[] words = value.Split(' ');
foreach(string word in words)
{
if( word.Trim().Length > maxLenght)
return false;
}
return true;
}
}
Then call it like this (it will trim of leading and trailing whitespaces if
there are any).
string message ="This is a message";
bool ret = StringUtil.IsValidWordLenght(message, 100);
HTH,
//Andreas
"Aaron" <ku*****@yahoo.com> skrev i meddelandet
news:OP**************@TK2MSFTNGP12.phx.gbl...
DOes anyone know how to check the length of words in a string?
I want all the word in a string to be less than 100 char to prevent buffer
overflow.
Thanks.
Aaron