String 处理 Code highlighting produced by Actipro CodeHighlighter (freeware)/-->using System; using ; using ; using ; using ; using ; using ; using ; using ; using ; using ; namespace { /// <summary> /// 字符串数据数据处理扩展类/// </summary> /// <remarks> 字符串数据数据处理扩展类</remarks> public static class StringHelper { #region 字符串格式转换///<summary> /// 把一个字符串截取成数据返回///</summary> ///<param name="s"> 目标字符串</param> ///<param name="sep"> 分割标示符</param> ///<returns> 返回一个分割出来的数组</returns> public static string[] ToArray(this string s, string sep) { int sepLen = ; ArrayList arr = new ArrayList(); string item; int pos; if (sep != "") { while (true) { pos = (sep); if (pos > 0) { item = (0, pos); (item); if (sepLen + pos >= ) break; s= (sepLen + pos, - sepLen - pos); } else if (pos == 0) { if (sepLen >= ) break; s= (sepLen, - sepLen); } else { if ( > 0) (s); break; } }} else { char[] arr_str = (); for (int i= 0;i< (0); i++) { (arr_str[i].ToString()); }} string[] result = new string[]; (result); return result; } /// <summary> /// 将字符串转化成 Byte[] /// </summary> public static Byte[] ToByteArray(this string s) { return (( (s))); } /// <summary> /// 将 Byte[] 转化成字符串/// </summary> public static string ToByteString(this byte[] s) { return (s); } /// <summary> /// 将字符串转化成 XML /// </summary> public static XmlDocument ToXml(this string s) { XmlDocument xmldoc = new XmlDocument(); (new (("GB 2312").GetBytes(s))); return xmldoc; } ///<summary> /// 把一个字符串截取成数据返回///</summary> ///<param name="s"> 目标字符串</param> ///<param na
String处理 来自淘豆网m.daumloan.com转载请标明出处.