Mono Class Library: System.String Overview | Members

System.String.Length Property

Gets the number of characters in the current instance. [Edit]

public int Length { get; }

Value

A int containing the number of characters in the current instance. [Edit]

Remarks

This property is read-only. [Edit]

Example

The following example demonstrates the string.Length property.

C# Example
using System;
public class StringLengthExample {
 public static void Main() {
 string str = "STRING";
 Console.WriteLine( "The length of string {0} is {1}", str, str.Length );
 }
}

The output is

The length of string STRING is 6

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0