字符串分割新增分割字符串参数
This commit is contained in:
parent
58e6f5872f
commit
a85e48dbc7
@ -10,21 +10,22 @@ namespace ZR.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 要分割的字符串 eg: 1,3,10,00
|
/// 要分割的字符串 eg: 1,3,10,00
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="infoIds"></param>
|
/// <param name="str"></param>
|
||||||
|
/// <param name="split">分割的字符串</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static long[] SpitLongArrary(string str)
|
public static long[] SpitLongArrary(string str, char split = ',')
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(str)) { return Array.Empty<long>(); }
|
if (string.IsNullOrEmpty(str)) { return Array.Empty<long>(); }
|
||||||
str = str.TrimStart(',').TrimEnd(',');
|
str = str.TrimStart(split).TrimEnd(split);
|
||||||
string[] strIds = str.Split(',', (char)StringSplitOptions.RemoveEmptyEntries);
|
string[] strIds = str.Split(split, (char)StringSplitOptions.RemoveEmptyEntries);
|
||||||
long[] infoIdss = Array.ConvertAll(strIds, s => long.Parse(s));
|
long[] infoIdss = Array.ConvertAll(strIds, s => long.Parse(s));
|
||||||
return infoIdss;
|
return infoIdss;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] SpitIntArrary(string str)
|
public static int[] SpitIntArrary(string str, char split = ',')
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(str)) { return Array.Empty<int>(); }
|
if (string.IsNullOrEmpty(str)) { return Array.Empty<int>(); }
|
||||||
string[] strIds = str.Split(',', (char)StringSplitOptions.RemoveEmptyEntries);
|
string[] strIds = str.Split(split, (char)StringSplitOptions.RemoveEmptyEntries);
|
||||||
int[] infoIdss = Array.ConvertAll(strIds, s => int.Parse(s));
|
int[] infoIdss = Array.ConvertAll(strIds, s => int.Parse(s));
|
||||||
return infoIdss;
|
return infoIdss;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user