0
我收到此错误,我似乎无法得到原因。“当我尝试创建子字符串时,索引和长度必须指向字符串中的某个位置
private void MessageReceived(String message)
{
int beginIndex = message.IndexOf(":");
String index = message.Substring(1, beginIndex - 1);
if (index == "SHOW_TIME")
{
String time = message.Substring(11, message.Length -1);
if (alarm == time)
{
MessageBox.Show("ALARM ALARM ALARM ALARM");
}
}
}
当程序到达字符串时间行时,错误会弹出。
假设您的字符串(消息)不包含':'或者其长度小于11 –
消息字符串包含:#SHOW_TIME:XXXX% – user3236510