স্ট্রিংয়ের দৈর্ঘ্য পেতে C# এ String.Length বৈশিষ্ট্যটি ব্যবহার করুন।
str.Length
প্রপার্টি স্ট্রিং-এর শব্দগুলি গণনা করে এবং নির্দিষ্ট স্ট্রিংটির দৈর্ঘ্য প্রদর্শন করে, উদাহরণস্বরূপ, স্ট্রিং অমিটে 4টি অক্ষর রয়েছে −
string str = "Amit";
উদাহরণ
স্ট্রিং দৈর্ঘ্য −
গণনা করার জন্য নিম্নলিখিত C# প্রোগ্রামusing System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
string str = "Amit";
Console.WriteLine("String: "+str);
Console.WriteLine("String Length: "+str.Length);
Console.ReadKey();
}
}
} আউটপুট
String: Amit String Length: 4