spilt用法简介
//获取墓位位置 string MWFLMC = "和平区祥和园D组A碑11排"; //得到字符数组 string[] sArray1 = new string[5]; //分割字符数组 sArray1 = MWFLMC.Split(new char[5] { '区', '园', '组', '碑', '排' }); if (sArray1.Length > 0) {
//和平 reportdoc.DataDefinition.FormulaFields["Q"].Text = "'" + sArray1[0] + "'"; } if (sArray1.Length > 1) {
//祥和 reportdoc.DataDefinition.FormulaFields["Y"].Text = "'" + sArray1[1] + "'"; } if (sArray1.Length > 2) {
//D reportdoc.DataDefinition.FormulaFields["Z"].Text = "'" + sArray1[2] + "'"; } if (sArray1.Length > 4) {
//A reportdoc.DataDefinition.FormulaFields["B"].Text = "'" + sArray1[3] + "'"; } if (sArray1.Length > 5) {
//11 reportdoc.DataDefinition.FormulaFields["P"].Text = "'" + sArray1[4] + "'"; } int b = MWFLMC.IndexOf("排"); reportdoc.DataDefinition.FormulaFields["H"].Text = "'" + MWFLMC.Substring(b + 1, MWFLMC.Length - b - 2) + "'";