স্ট্রিং-এ 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