判断是否有重复,判断字符串是否有重复汉字【c#】

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;
            }

  

posted @ 2021-09-06 13:38  刘贵庆  阅读(159)  评论(0编辑  收藏  举报