C# 按指定数量从前面或者后面删除字符串
/// <summary> /// 从字符串前面删除指定字符个数 /// </summary> /// <param name="s">字符串</param> /// <param name="len">个数</param> /// <returns>返回删除后的字符串</returns> public static string RemoveLeft(string s, int len) { return s.PadLeft(len).Remove(0, len); } /// <summary> /// 从字符串后面删除指定字符个数 /// </summary> /// <param name="s">字符串</param> /// <param name="len">个数</param> /// <returns>返回删除后的字符串</returns> public static string RemoveRight(string s, int len) { s = s.PadRight(len); return s.Remove(s.Length - len, len); }