怎样获取数据库字段中,,之间的字符?
数据库字段p_length 里面有 ,27,30, 我想单独获取27 然后付给变量 p_id
说明一下:p_length里每行数据都不一样 有 ,1,5, 或者 ,180,205, 获取第一个 ,,之间的字符个数不等;
请大侠指点一下,怎么做?
[解决办法]
[align=left] string TargeStr = ",1,5,9,13,15,17,19,21,"; if (TargeStr.StartsWith(",") == true) { string[] strArray = TargeStr.Trim(new char[] { ',' }).Split(','); for (int i = 0; i < strArray.Length; i++) { Response.Write("Index of " + i + " : " + strArray[i] + "<br>"); } }[/align]
[解决办法]
[Quote=引用:]
string TargeStr = ",1,5,9,13,15,17,19,21,"; if (TargeStr.StartsWith(",") == true) { string[] strArray = TargeStr.Trim(new char[] { ',' }).Split(','); for (int i = 0; i < strArray.Length; i++) { Response.Write("Index of " + i + " : " + strArray[i] + "<br>"); } }
[解决办法]