先看看方法吧,很简单的方法
/// <summary>
/// 取字符的方法
/// </summary>
/// <param name="sourceStr">源字符串</param>
/// <param name="strOf">变量名称</param>
/// <returns>返回变量后面的值</returns>
private string smsindexOf(string sourceStr, string strOf)
{
sourceStr = sourceStr.Substring(sourceStr.IndexOf(strOf + "="), sourceStr.Length - sourceStr.IndexOf(strOf + "=") - 6);
sourceStr = sourceStr + "&";
sourceStr = sourceStr.Substring(sourceStr.IndexOf("=") + 1, sourceStr.IndexOf("&") - sourceStr.IndexOf("=") - 1);
return sourceStr;
}
下在是使用方法
示例字符
result=0&des=OK&mobile=13167507389&content=123&recvtime=2009-1-1 12:00:00&mobile=13167507389&content=123&recvtime=2009-2-2 12:00:00
if (strsms.IndexOf("des=") >= 0)
{
string strSms = smsindexOf(strsms, "des");
}