.net中string无重复数字的实现方法

时间:2022-09-15 15:08:06

代码如下:


//string strText = "1334677999";实现无重复
        public static string qu(string lab)
        {
            string strResult = string.Empty;
            for (int intIdx = 0; intIdx < lab.Length; intIdx++)
            {
                if (strResult.IndexOf(lab.Substring(intIdx, 1)) < 0)
                {
                    strResult += lab.Substring(intIdx, 1);
                }
            }
            return strResult;
        }