C# Join() 方法用於連接數組的元素,在每個元素之間使用指定的分隔符。它返回一個修改後的字符串。
簽名
[ComVisibleAttribute(false)]
public static string Join(String first, params String[] second)
[ComVisibleAttribute(false)]
public static string Joint(String, params Object[])
[ComVisibleAttribute(false)]
public static string Join (String, IEnumerable<String>)
[ComVisibleAttribute(false)]
public static string Join(String, String[], Int32, Int32)
[ComVisibleAttribute(false)]
public static string Join<T>(String, IEnumerable <T>)
參數
first:它是一個字符串類型參數。
second:它是一個字符串數組。
返回
它返回一個字符串。
C# 字符串 Join() 方法示例
using System;
public class StringExample
{
public static void Main(string[] args)
{
string[] s1 = {"Hello","C#","by","javatpoint"};
string s3 = string.Join("-",s1);
Console.WriteLine(s3);
}
}
輸出:
Hello-C#-by-javatpoint
相關用法
- C# String ToLower()用法及代碼示例
- C# String ToString()用法及代碼示例
- C# String Contains()用法及代碼示例
- C# String ToCharArray()用法及代碼示例
- C# String IndexOf()用法及代碼示例
- C# String TrimEnd()用法及代碼示例
- C# String IsNormalized()用法及代碼示例
- C# String Concat()用法及代碼示例
- C# String GetTypeCode()用法及代碼示例
- C# String Equals()用法及代碼示例
- C# String Split()用法及代碼示例
- C# String SubString()用法及代碼示例
- C# String Normalize()用法及代碼示例
- C# String Compare()用法及代碼示例
- C# String LastIndexOfAny()用法及代碼示例
- C# String EndsWith()用法及代碼示例
- C# String Trim()用法及代碼示例
- C# String Copy()用法及代碼示例
- C# String PadLeft()用法及代碼示例
- C# String GetType()用法及代碼示例
注:本文由純淨天空篩選整理自 C# String Join()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。