From 0064ceda3df97f72d224055acf67fb786bd3ad10 Mon Sep 17 00:00:00 2001
From: falcon <9504402@qq.com>
Date: Tue, 24 May 2022 10:33:53 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=89=A9=E5=B1=95?=
=?UTF-8?q?=E5=88=86=E5=89=B2=E5=A2=9E=E5=8A=A0=E4=BA=86=E8=87=AA=E5=AE=9A?=
=?UTF-8?q?=E4=B9=89=E5=88=86=E9=9A=94=E7=AC=A6=E5=8F=82=E6=95=B0=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Falcon.SugarApi/StringExtend.cs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Falcon.SugarApi/StringExtend.cs b/Falcon.SugarApi/StringExtend.cs
index d165a8b..41ee913 100644
--- a/Falcon.SugarApi/StringExtend.cs
+++ b/Falcon.SugarApi/StringExtend.cs
@@ -12,19 +12,21 @@ namespace Falcon.SugarApi
///
/// 字符串
/// 空或null为True,否则False
- public static bool IsNullOrEmpty(this string str) => str == null || string.IsNullOrEmpty(str);
+ public static bool IsNullOrEmpty(this string? str) => str == null || string.IsNullOrEmpty(str);
///
/// 字符串是否不为空或null
///
/// 字符串
/// 与IsNullOrEmpty相反
- public static bool IsNotNullOrEmpty(this string str) => !str.IsNullOrEmpty();
+ public static bool IsNotNullOrEmpty(this string? str) => !str.IsNullOrEmpty();
///
/// 使用全角半角的逗号句号和分号分割字符串。
///
/// 要分割的字符串
+ ///
/// 字符串数组。当str为null时返回空数组
- public static string[] SplitStr(this string? str) => str == null ? Array.Empty() : str.Split(new char[] { ',', ',', ';', ';', '.', '。' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+ public static string[] SplitStr(this string? str, params char[] splitChars)
+ => str.IsNullOrEmpty() ? Array.Empty() : str.Split(splitChars.Length == 0 ? new char[] { ',', ',', ';', ';', '.', '。' } : splitChars, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
}
}