Files
KJD/AllBase/ConvertExtension.cs
2025-06-29 19:38:31 +08:00

33 lines
907 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AllBase
{
public static class ConvertExtension
{
/// <summary>
/// 删除特殊字符 by ttzhao 2020.6.20
/// </summary>
/// <param name="text"></param>
/// <param name="characters"></param>
/// <returns></returns>
public static string RemoveSpecialChar(this string text, params string[] characters)
{
//{ ":", ":", "/", "\\", "\"", "?", "✅", "◆", "‼️" }
string str = text;
List<string> specialCharacters = new List<string>(characters);
specialCharacters.ForEach(c =>
{
if (c.Length > 0)
str = str.Replace(c, "");
});
return str;
}
}
}