用C#写的输出字符串中出现过的所有字符,相同字符只输出一次

        string str = "AAABBCCCC";

        string strI = str[0].ToString();
        string strChild = str[0].ToString();
        for (int i = 0; i < str.Length; i++)
        {
            if (strI != str[i].ToString())
            {
                strI = str[i].ToString();
                strChild += str[i].ToString();
            }
        }
        Response.Write(strChild);

posted on 2008-04-09 13:45  星答  阅读(551)  评论(0编辑  收藏  举报