From 099bbe56a39003f14f11e322398e420c28775b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=9D=B0?= <309530474@qq.com> Date: Tue, 12 May 2020 16:37:55 +0800 Subject: [PATCH] =?UTF-8?q?update=20DotNet.Utilities/=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2/StringHelper.cs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StringHelper.cs" | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git "a/DotNet.Utilities/\345\255\227\347\254\246\344\270\262/StringHelper.cs" "b/DotNet.Utilities/\345\255\227\347\254\246\344\270\262/StringHelper.cs" index 8161536..9b174e1 100644 --- "a/DotNet.Utilities/\345\255\227\347\254\246\344\270\262/StringHelper.cs" +++ "b/DotNet.Utilities/\345\255\227\347\254\246\344\270\262/StringHelper.cs" @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; @@ -21,6 +21,7 @@ namespace DotNet.Utilities /// 12、GetNewStyle(string StrList, string NewStyle, string SplitString, out string Error)将字符串转换为新样式 /// 13、SplitMulti(string str, string splitstr)分割字符串 /// 14、SqlSafeString(string String, bool IsDel) + /// 15. GetStrArray(string str, string[] speaters, bool toLower = false)把字符串按照分隔符转换成 IEnumerable /// public class StringHelper { @@ -563,5 +564,25 @@ namespace DotNet.Utilities return false; } #endregion + + /// + /// 把字符串按照分隔符转换成 IEnumerable + /// + /// 源字符串 + /// 分隔符集合 + /// 是否转换为小写,默认小写 + /// + public static IEnumerable GetStrArray(string str, string[] speaters, bool toLower = false) + { + foreach (string s in str.Split(speaters, StringSplitOptions.RemoveEmptyEntries)) + { + string temp = s.Trim(); + if (!string.IsNullOrEmpty(temp)) + { + yield return toLower ? temp.ToLower() : temp; + } + } + } + } } -- Gitee