প্রথম অক্ষর পেতে, substring() পদ্ধতি ব্যবহার করুন।
ধরা যাক নিচের isour স্ট্রিং -
string str = "Welcome to the Planet!";
এখন প্রথম অক্ষর পেতে, মান 1 সাবস্ট্রিং() পদ্ধতিতে সেট করুন।
string res = str.Substring(0, 1);
আসুন সম্পূর্ণ কোডটি দেখি -
উদাহরণ
using System;
public class Demo {
public static void Main() {
string str = "Welcome to the Planet!";
string res = str.Substring(0, 1);
Console.WriteLine(res);
}
} আউটপুট
W