使用c#使用gsm modam发送短信并且消息长度太短

时间:2019-01-11 09:21:44

标签: c# gsm

我在C#中构建了一个SMS应用程序,但是当我发送一条消息时,只会发送150个字符的消息。 但是我的客户要求是发送150个以上的字符。

我该怎么解决?

1 个答案:

答案 0 :(得分:0)

您可以在发送消息/ SMS之前获取string的计数,然后根据字符数Spilt将其计数并单独发送。

 string strValue = "qwertyui oplkjhgfds azxcvb nm,. ;'[poerern asyqawqwdhkas,mdbn ahwdasda doiashdkjabdamd aiuasdghkjabdan dakshdkajdbkasdvsa askldhkajdahvd asdhkakjdad kahsdjbajkdbasd";
 int nLength = strValue.Length;

 if (nLength > 150)
 {
    //You can give the count in which you want to spilt the string
    var regex = new Regex(@".{100}");
    string result = regex.Replace(strValue, "$&" + Environment.NewLine+ Environment.NewLine);
    MessageBox.Show(result);
 }

输出结果

String spilt based on character count