Language
Version: 5
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
Strings
Strings
String Length in C#
Returns the number of characters in a string.
Syntax
int length = stringName.Length;
Notes
Spaces count as characters.
Example
string name = "Anthony";
int nameLength = name.Length;
Console.WriteLine("The name " + name + " contains " + nameLength + "letters.");