C# String TrimStart

Description

String TrimStart removes all leading occurrences of a set of characters specified in an array from the current String object.

Syntax

String.TrimStart has the following syntax.


public string TrimStart(
  params char[] trimChars
)

Parameters

String.TrimStart has the following parameters.

  • trimChars - An array of Unicode characters to remove, or null.

Returns

String.TrimStart method returns The string that remains after all occurrences of characters in the trimChars parameter are removed from the start of the current string. If trimChars is null or an empty array, white-space characters are removed instead.

Example

The following example then illustrates a call to the String.TrimStart method.


// w w  w .  ja  va  2s . co  m
using System;
public class MainClass{
  public static void Main(String[] argv){  
       string s = " this is a test "; 
       Console.WriteLine(s.TrimStart());
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version