zoukankan      html  css  js  c++  java
  • C# string.join

    String.Join 方法 

    平常工作中经常用到string.join()方法,在vs 2017用的运行时(System.Runtime, Version=4.2.0.0)中,共有九个(重载)方法。

    //
            // 摘要:
            //     Concatenates the members of a collection, using the specified separator between
            //     each member.
            //
            // 参数:
            //   separator:
            //     The string to use as a separator.separator is included in the returned string
            //     only if values has more than one element.
            //
            //   values:
            //     A collection that contains the objects to concatenate.
            //
            // 类型参数:
            //   T:
            //     The type of the members of values.
            //
            // 返回结果:
            //     A string that consists of the members of values delimited by the separator string.
            //     If values has no members, the method returns System.String.Empty.
            //
            // 异常:
            //   T:System.ArgumentNullException:
            //     values is null.
            public static String Join<T>(String separator, IEnumerable<T> values);
            //
            // 摘要:
            //     Concatenates the members of a constructed System.Collections.Generic.IEnumerable`1
            //     collection of type System.String, using the specified separator between each
            //     member.
            //
            // 参数:
            //   separator:
            //     The string to use as a separator.separator is included in the returned string
            //     only if values has more than one element.
            //
            //   values:
            //     A collection that contains the strings to concatenate.
            //
            // 返回结果:
            //     A string that consists of the members of values delimited by the separator string.
            //     If values has no members, the method returns System.String.Empty.
            //
            // 异常:
            //   T:System.ArgumentNullException:
            //     values is null.
            public static String Join(String separator, IEnumerable<String> values);
            //
            // 摘要:
            //     Concatenates the elements of an object array, using the specified separator between
            //     each element.
            //
            // 参数:
            //   separator:
            //     The string to use as a separator. separator is included in the returned string
            //     only if values has more than one element.
            //
            //   values:
            //     An array that contains the elements to concatenate.
            //
            // 返回结果:
            //     A string that consists of the elements of values delimited by the separator string.
            //     If values is an empty array, the method returns System.String.Empty.
            //
            // 异常:
            //   T:System.ArgumentNullException:
            //     values is null.
            public static String Join(String separator, params object[] values);
            //
            // 摘要:
            //     Concatenates all the elements of a string array, using the specified separator
            //     between each element.
            //
            // 参数:
            //   separator:
            //     The string to use as a separator. separator is included in the returned string
            //     only if value has more than one element.
            //
            //   value:
            //     An array that contains the elements to concatenate.
            //
            // 返回结果:
            //     A string that consists of the elements in value delimited by the separator string.
            //     If value is an empty array, the method returns System.String.Empty.
            //
            // 异常:
            //   T:System.ArgumentNullException:
            //     value is null.
            public static String Join(String separator, params String[] value);
            //
            // 摘要:
            //     Concatenates the specified elements of a string array, using the specified separator
            //     between each element.
            //
            // 参数:
            //   separator:
            //     The string to use as a separator. separator is included in the returned string
            //     only if value has more than one element.
            //
            //   value:
            //     An array that contains the elements to concatenate.
            //
            //   startIndex:
            //     The first element in value to use.
            //
            //   count:
            //     The number of elements of value to use.
            //
            // 返回结果:
            //     A string that consists of the strings in value delimited by the separator string.
            //     -or- System.String.Empty if count is zero, value has no elements, or separator
            //     and all the elements of value are System.String.Empty.
            //
            // 异常:
            //   T:System.ArgumentNullException:
            //     value is null.
            //
            //   T:System.ArgumentOutOfRangeException:
            //     startIndex or count is less than 0. -or- startIndex plus count is greater than
            //     the number of elements in value.
            //
            //   T:System.OutOfMemoryException:
            //     Out of memory.
            public static String Join(String separator, String[] value, int startIndex, int count);
            //
            // 参数:
            //   separator:
            //
            //   value:
            public static String Join(char separator, params String[] value);
            //
            // 参数:
            //   separator:
            //
            //   value:
            //
            //   startIndex:
            //
            //   count:
            public static String Join(char separator, String[] value, int startIndex, int count);
            //
            // 参数:
            //   separator:
            //
            //   values:
            public static String Join(char separator, params object[] values);
            //
            // 参数:
            //   separator:
            //
            //   values:
            //
            // 类型参数:
            //   T:
            public static String Join<T>(char separator, IEnumerable<T> values);
    string.Join 重载方法详解

    所以平常写方法的时候,基本上都覆盖了。

    常用方法:separator以“,”为例。

    string.Join(',',string[])   //字符','分割,拼接字符串数组

    string.Join(',',List<string>)  //字符','分割,拼接字符串列表  

    string.Join(",",string[])   //字符串“,”分割,拼接字符数组

    string.Join(",",List<string>)  //字符串“,”分割,拼接字符数组

    备注:vs2013中重载方法没有这么多,需注意。

  • 相关阅读:
    将小度WiFi改造为无线网卡(小度WiFi能够接收WiFi信号)
    百度8秒教育片
    MATLAB r2014a 下载+安装+激活
    lsmod
    ipython与python的区别
    ssh远程登录Ubuntu报错:Permission denied, please try again.
    windows系统安装ubuntu后,grub中没有windows启动项
    面向对象三大特征
    进程和线程
    tar 命令
  • 原文地址:https://www.cnblogs.com/meng9527/p/9089615.html
Copyright © 2011-2022 走看看