C# String Length
Description
String Length
gets the number of characters in the current
String object.
Syntax
String.Length
has the following syntax.
public int Length { get; }
Example
The following example demonstrates the Length property.
using System;// w w w . j a v a2 s . co m
class Sample
{
public static void Main()
{
string str = "java2s.com";
Console.WriteLine("1) The length of '{0}' is {1}", str, str.Length);
Console.WriteLine("2) The length of '{0}' is {1}", "xyz", "xyz".Length);
}
}
The code above generates the following result.