string corn = "公司"; int n = 0; if (tbCorporateName.Text.IndexOf(corn) > -1) { string cor = tbCorporateName.Text.Replace(corn, ""); n = (tbCorporateName.Text.Length - cor.Length) / corn.Length; } if (n >= 2) { lblMessage.Text = "请输入单个公司名称。"; Result = false; }