Languages
[Edit]
EN

C# / .NET - string Join() method example

0 points
Created by:
Trenton-McKinney
618

In this article, we would like to show you string Join() method example in C#.

Quick solution:

 

1. Documentation

Edit
Syntaxpublic static string Join(string separator, params obj[] array)
Parameters

separator- a sequence of characters that is used to separate each of the elements,

params - the elements to join together.

Resulta new String that is composed of the elements separated by the separator
DescriptionThe method returns a new String composed of copies of the params elements joined together with a copy of the specified separator.

2. Practical examples

Edit

C# string Join() method returns a string joined with a given separator which is copied for each element.

Example 1

Edit

In this example, we join string elements with an empty string as a separator.

Output:

Example 2

Edit

In this example, we use Join() method with - as a separator to display string elements as a date.

Output:

References

Edit
  1. String.Join Method (System) | Microsoft Docs 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join