string.Join divided into the following five categories of usage have to explain.
HashSet<string> hs = new HashSet<string>();
hs.Add("111");
hs.Add("222");
hs.Add("333");
var str = string.Join(",", hs);
Console.WriteLine(str);
#region // Summary: // series member of the set wherein the specified separator between each member. // Parameters: // Separator: // be used as string delimiter. Only elements having a plurality of values, separator was included in the returned string. // values: // a collection that contains the object to be connected in series. // type parameter: // T: // type values members. // Returns: // A string of values consisting of members, the members separated in separator string. If no member of values, the method returns System.String.Empty. // an exception: // T: System.ArgumentNullException: // values is null. [The ComVisible ( to false )] public staticThe Join String <T> (String Separator, the IEnumerable <T> values); // // Summary: // tandem type configuration System.Collections.Generic.IEnumerable`1 member System.String set, wherein each member between the specified delimiters. // // Parameters: // Separator: // be used as string delimiter. Only elements having a plurality of values, separator was included in the returned string. // // values: // a collection that contains the string to be connected in series. // // Returns: // A string of values consisting of members, the members separated in separator string. If no member of values, the method returns System.String.Empty. // // anomaly: // T: System.ArgumentNullException: // values is null. [The ComVisible ( to false )] public static String the Join (String Separator, the IEnumerable <String> values); // // Summary: // series specified string array element, using the specified separator between each element. // // Parameters: // Separator: // be used as string delimiter. Only when a plurality of elements having a separator, value was included in the returned string. // // value: // An array that contains the elements you want to connect. // // startIndex: // first element value to be used. // // COUNT: // number of elements to be used for value. // // Returns: //By the value of the string of the strings, the strings separated by separator string. - or - if System.String.Empty zero, COUNT // no element, or all of the elements of value and separator are value, compared with System.String.Empty. // // anomaly: // T: System.ArgumentNullException: // value is null. // // T: System.ArgumentOutOfRangeException: // startIndex or count is less than 0. - or - startIndex plus count value is greater than the number of elements. // // T: System.OutOfMemoryException: // Out of memory. [SecuritySafeCritical] public static String the Join (String Separator, String [] value, int startIndex, int COUNT); // // Summary: // series string array of all the elements, wherein the specified separator between each element. // // Parameters: // Separator: // be used as string delimiter. Only when a plurality of elements having a separator, value was included in the returned string. // // value: // An array that contains the elements you want to connect. // // Returns: // a string by the value of the elements, these elements separated by separator string. If the value is an empty array, the method returns System.String.Empty. // // anomaly: // T: System.ArgumentNullException: // value is null. public static String the Join (String Separator, the params String [] value); // // Summary: // series of individual elements of an array of objects, using the specified separator between each element. // // Parameters: // Separator: // be used as string delimiter. Only when the separator having a plurality of elements, values was included in the returned string. // // values: // An array that contains the elements you want to connect. // // Returns: // a string consisting of values of the elements, these elements are separated by separator string. If values is empty array, the method returns System.String.Empty. // // anomaly: // T: System.ArgumentNullException: // values is null. [The ComVisible ( to false )] public static String the Join (String Separator, the params Object [] values);
Reproduced in: https: //www.cnblogs.com/wangjunguang/p/11122145.html