zoukankan      html  css  js  c++  java
  • C# 扩展 string Split 方法

    // 使用扩展方法做
    public static string[] SplitExt(this string sourceString, string splitString)
    {
        List
    <string> arrayList = new List<string>();
        
    string s = string.Empty;
        
    while (sourceString.IndexOf(splitString) > -1)
        {
            s 
    = sourceString.Substring(0, sourceString.IndexOf(splitString));
            sourceString 
    = sourceString.Substring(sourceString.IndexOf(splitString) + splitString.Length);
            arrayList.Add(s);
        }
        arrayList.Add(sourceString);
        
    return arrayList.ToArray();
    }

    // 使用普通方法做
    public static string[] StringSplitExt(string sourceString, string splitString)
    {
        List
    <string> arrayList = new List<string>();
        
    string s = string.Empty;
        
    while (sourceString.IndexOf(splitString) > -1)
        {
            s 
    = sourceString.Substring(0, sourceString.IndexOf(splitString));
            sourceString 
    = sourceString.Substring(sourceString.IndexOf(splitString) + splitString.Length);
            arrayList.Add(s);
        }
        arrayList.Add(sourceString);
        
    return arrayList.ToArray();
    }
  • 相关阅读:
    avalon随笔
    ms-attr-data-real-gold="{{page_data[0].gold}}" 属性付真
    jQuery 快捷操作
    jQuery 属性操作
    jQuery 表单域选中选择器
    jQuery 层次选择器
    jQuery 基本选择器
    jQuery 基本使用
    jQuery 引入多个库文件冲突
    BOM window对象方法
  • 原文地址:https://www.cnblogs.com/anjou/p/1585852.html
Copyright © 2011-2022 走看看