admin
2024-09-20 8b7b39172ee548ff303dbd73816cb7c1071f7887
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
 
namespace CommonHelper
{
    /// <summary>
    /// 字符串对象扩展方法。
    /// </summary>
    public static class ExtString
    {
 
        /// <summary>
        /// 判断字符串是否为空。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this string str)
        {
            return string.IsNullOrEmpty(str);
        }
 
        /// <summary>
        /// 字符串分割成字符串数组。
        /// </summary>
        /// <param name="str"></param>
        /// <param name="separator">分隔符,默认为逗号。</param>
        /// <returns></returns>
        public static string[] ToStrArray(this string str, string separator = ",")
        {
            return str.Split(new string[] { separator }, StringSplitOptions.RemoveEmptyEntries);
        }
    }
}