将字符串中从n位开始以*代替

/// <summary>
    /// 将字符串中从n位开始以*代替
    /// </summary>
    /// <param name="str">字符串</param>
    /// <param name="starIndex">开始位置</param>
    /// <returns></returns>
    public static string GetPingbStr(string str, int starIndex)
    {
        string strend = "";
        if (str.Length >= starIndex)
        {
            for (int i = 0; i < str.Length - (starIndex); i++)
            {
                strend += "*";
            }
            str = str.Substring(0, starIndex);
        }
        else
            strend = str;
        return str + strend;
    }

 

posted @ 2012-12-27 01:02  xyzhuzhou  阅读(298)  评论(0编辑  收藏  举报