C# String StartsWith(String)

Description

String StartsWith(String) determines whether the beginning of this string instance matches the specified string.

Syntax

String.StartsWith(String) has the following syntax.


public bool StartsWith(
  string value
)

Parameters

String.StartsWith(String) has the following parameters.

  • value - The string to compare.

Returns

String.StartsWith(String) method returns true if value matches the beginning of this string; otherwise, false.

Example

The following example demonstrates how you can use the StartsWith method.


using System;/* ww w . ja  v  a  2s  . c o  m*/

public class EndsWithTest {
    public static void Main() {
      Console.WriteLine("java2s.com".StartsWith("java"));
    }
}

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