ningshuxia
2025-03-13 25d1bf4c50f43cf6690c5ac92824959865c9d78f
Service/HStation.Service.Assets.Core/05-service/00-core/03-helper/KeyWordHelper.cs
@@ -1,25 +1,37 @@
namespace HStation.Service
namespace HStation.Service.Assets
{
    /// <summary>
    ///
    /// </summary>
    public class KeyWordHelper
    {
        public static List<string> ToList(string keyword)
        {
            if (string.IsNullOrEmpty(keyword))
            {
                return new List<string>();
            }
            return keyword.Split(new string[1] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
        //分割字符
        private const char _split = ',';
        public static string ToString(List<string> KeyWord)
        /// <summary>
        /// 转化为字符串
        /// </summary>
        public static string ToString(IEnumerable<string> list)
        {
            if (KeyWord == null || KeyWord.Count < 1)
            if (list == null || list.Count() < 1)
            {
                return string.Empty;
            }
            return string.Join(",", KeyWord);
            return string.Join(_split.ToString(), list.Select(x => x.Trim()));
        }
        /// <summary>
        /// 转化为列表
        /// </summary>
        public static List<string> ToList(string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return new List<string>();
            }
            return str.Split(_split, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();
        }
    }
}