C#-এ String.Join() মেথড একটি স্ট্রিং অ্যারের সব উপাদানকে একটি নির্দিষ্ট সেপারেটর (বিভাজক) দিয়ে একসাথে জোড়া দেয়।
নিচের উদাহরণে আমরা একটি মাল্টি-লাইন স্ট্রিং অ্যারে ব্যবহার করেছি এবং সেপারেটর হিসেবে "\n" (নিউ লাইন) ব্যবহার করেছি:
String.Join("\n", starray);
সম্পূর্ণ উদাহরণ
using System;
namespace StringApplication {
class StringProg {
static void Main(string[] args) {
string[] starray = new string[]{
"Down the way nights are dark",
"And the sun shines daily on the mountaintop",
"I took a trip on a sailing ship",
"And when I reached Jamaica",
"I made a stop"
};
string str = String.Join("\n", starray);
Console.WriteLine(str);
}
}
}
আউটপুট
Down the way nights are dark And the sun shines daily on the mountain top I took a trip on a sailing ship And when I reached Jamaica I made a stop