hi,
i am writing a code sending a messages to mobiles, my aim is if user enter morethan 150 characters that time 0 to 150 characters are send to one message. and remaing between 151 to 300 characters are send to 2nd message.
I write substring like:
string msg=TxtMessage.Text;
int count = msg.Length;
int x = 0;
while (x <= count)
{
string imsg = msg.Substring(x, 150);
// Send message logic here
x += 150;
}
using this it work only if user enter 150 or 300 or 450 characters. if user enter 50 0r 200 etxc characters it is not work. it display error that is., "Index and length must refer to a location within the string. Parameter name: length". i understand this error message,
but how to write the substring function using this type of application. my aim is one message send lessthan 151 characters(0 to 150) and 2nd message send between 151 to 300 characters.
Please give a code todo this.
Thanks.