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
Post a Comment