String.Split


public
static class StringHelper { /// <summary> /// convert string to list by separators /// </summary> /// <param name="str">the string you want to deal with</param> /// <param name="separators">the separator char array </param> /// <returns></returns> public static List<string> StringToListBySeparators(this string str, char[] separators) { string[] strs = str.Split(separators); List<string> liststr = new List<string>(strs); return liststr; } /// <summary> /// convert string to list by separators /// </summary> /// <param name="str">the string you want to deal with</param> /// <param name="separators">the separator string </param> /// <returns></returns> public static List<string> StringToListBySeparators(this string str, string separators) { string[] strs = Regex.Split(str, separators, RegexOptions.IgnoreCase); List<string> liststr = new List<string>(strs); return liststr; } /// <summary> /// convert string to list by separators /// </summary> /// <param name="str">the string you want to deal with</param> /// <param name="separators">the separator char </param> /// <returns></returns> public static List<string> StringToListBySeparators(this string str, char separators) { string[] strs = str.Split(separators); List<string> liststr = new List<string>(strs); return liststr; } }

 

你可能感兴趣的:(String)