Share via


Assert.StartsWith Method

Definition

Overloads

StartsWith(String, String, String)

Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring.

StartsWith(String, String, StringComparison, String)

Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring.

StartsWith(String, String, String)

Source:
Assert.StartsWith.cs

Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring.

public static void StartsWith(string? substring, string? value, string message = "");
static member StartsWith : string * string * string -> unit
Public Shared Sub StartsWith (substring As String, value As String, Optional message As String = "")

Parameters

substring
String

The string expected to be a prefix of value.

value
String

The string that is expected to begin with substring.

message
String

The message to include in the exception when value does not begin with substring. The message is shown in test results.

Exceptions

value is null, or substring is null, or value does not start with substring.

Applies to

StartsWith(String, String, StringComparison, String)

Source:
Assert.StartsWith.cs

Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring.

public static void StartsWith(string? substring, string? value, StringComparison comparisonType, string message = "");
static member StartsWith : string * string * StringComparison * string -> unit
Public Shared Sub StartsWith (substring As String, value As String, comparisonType As StringComparison, Optional message As String = "")

Parameters

substring
String

The string expected to be a prefix of value.

value
String

The string that is expected to begin with substring.

comparisonType
StringComparison

The comparison method to compare strings comparisonType.

message
String

The message to include in the exception when value does not begin with substring. The message is shown in test results.

Exceptions

value is null, or substring is null, or value does not start with substring.

Applies to