Get length of a string in C#

To get length of a string we use Length property of string. This returns an integer value indicating how many characters a string contains.

string str = "I like rain";
int length = str.Length;
Console.WriteLine("Length of str is " + length);

Output

Length of str is 11

Comments

Popular posts from this blog

Check if ViewBag is null or doesn't exist

Using Progress Bar In C#

Jquery serer side datatables in asp.net