zoukankan      html  css  js  c++  java
  • c# Split

    1. public string[] Split(params char[] separator)
    程序代码
    string[] split = words.Split(new Char[] { ',' });//返回:{"1","2.3","","4"}
    string[] split = words.Split(new Char[] { ',', '.' });//返回:{"1","2","3","","4"}

    2. public string[] Split(char[] separator, int count)
    程序代码
    string[] split = words.Split(new Char[] { ',', '.' }, 2);//返回:{"1","2.3,,4"}
    string[] split = words.Split(new Char[] { ',', '.' }, 6);//返回:{"1","2","3","","4"}

    3. public string[] Split(char[] separator, StringSplitOptions options)
    程序代码
    string[] split = words.Split(new Char[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素
    string[] split = words.Split(new Char[] { ',', '.' }, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素

    4. public string[] Split(string[] separator, StringSplitOptions options)
    程序代码
    string[] split = words.Split(new string[] { ",", "." }, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2","3","4"} 不保留空元素
    string[] split = words.Split(new string[] { ",", "." }, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素

    5. public string[] Split(char[] separator, int count, StringSplitOptions options)
    程序代码
    string[] split = words.Split(new Char[] { ',', '.' }, 2, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2.3,,4"} 不保留空元素
    string[] split = words.Split(new Char[] { ',', '.' }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素

    6. public string[] Split(string[] separator, int count, StringSplitOptions options)
    程序代码
    string[] split = words.Split(new string[] { ",", "." }, 2, StringSplitOptions.RemoveEmptyEntries);//返回:{"1","2.3,,4"} 不保留空元素
    string[] split = words.Split(new string[] { ",", "." }, 6, StringSplitOptions.None);//返回:{"1","2","3","","4"} 保留空元素

    需要注意的是没有重载函数public string[] Split(string[] separator),所以我们不能像VB.NET那样使用words.Split(","),而只能使用words.Split(',')

  • 相关阅读:
    委托事件
    委托使用(2)
    简单的文件流写读
    datalist 分页显示不用PagedDataSource对象
    委托使用(1)
    文件的路径问题
    委托揭秘
    一个简单的文件上传(没有数据库的)
    Quartz 2D 练习2多点触摸画圈
    插件框架精简版 x3py 已在Win/Mac/Linux下测试通过
  • 原文地址:https://www.cnblogs.com/future/p/10710394.html
Copyright © 2011-2022 走看看