Assert.EndsWith 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| EndsWith(String, String, StringComparison, String, String, String) |
測試指定字串是否以指定後綴結尾,若測試字串未以該後綴結尾,則拋出例外。 |
| EndsWith(String, String, String) |
測試指定字串是否以指定的子字串結尾,若測試字串不以該子字串結尾,則拋出例外。 |
| EndsWith(String, String, StringComparison, String) |
測試指定字串是否以指定的子字串結尾,若測試字串不以該子字串結尾,則拋出例外。 |
| EndsWith(String, String, String, String, String) |
測試指定字串是否以指定後綴結尾,若測試字串未以該後綴結尾,則拋出例外。 |
EndsWith(String, String, StringComparison, String, String, String)
測試指定字串是否以指定後綴結尾,若測試字串未以該後綴結尾,則拋出例外。
public static void EndsWith(string? expectedSuffix, string? value, StringComparison comparisonType, string? message = "", string expectedSuffixExpression = "", string valueExpression = "");
static member EndsWith : string * string * StringComparison * string * string * string -> unit
Public Shared Sub EndsWith (expectedSuffix As String, value As String, comparisonType As StringComparison, Optional message As String = "", Optional expectedSuffixExpression As String = "", Optional valueExpression As String = "")
參數
- expectedSuffix
- String
字串預期會是 的後綴 value。
- value
- String
預期以 結尾 expectedSuffix的字串。
- comparisonType
- StringComparison
比較字串 comparisonType的方法。
- message
- String
當 包含在例外 value 中的訊息不以 expectedSuffix結尾。 該訊息會顯示在測試結果中。
- expectedSuffixExpression
- String
預期後綴的語法表達式,由編譯器透過呼叫者參數表達式給出。 使用者不應該傳遞這個參數的值。
- valueExpression
- String
由編譯器透過呼叫者參數表達式所給出的語法表達式。 使用者不應該傳遞這個參數的值。
例外狀況
value 是空,或 expectedSuffix 是空,或 value 不以 expectedSuffix開頭。
適用於
EndsWith(String, String, String)
測試指定字串是否以指定的子字串結尾,若測試字串不以該子字串結尾,則拋出例外。
public static void EndsWith(string? substring, string? value, string message = "");
static member EndsWith : string * string * string -> unit
Public Shared Sub EndsWith (substring As String, value As String, Optional message As String = "")
參數
- substring
- String
字串預期會是 的後綴 value。
- value
- String
預期以 結尾 substring的字串。
- message
- String
當 包含在例外 value 中的訊息不以 substring結尾。 該訊息會顯示在測試結果中。
例外狀況
value 是空,或 substring 是零,或 value 不以 substring結尾。
適用於
EndsWith(String, String, StringComparison, String)
測試指定字串是否以指定的子字串結尾,若測試字串不以該子字串結尾,則拋出例外。
public static void EndsWith(string? substring, string? value, StringComparison comparisonType, string message = "");
static member EndsWith : string * string * StringComparison * string -> unit
Public Shared Sub EndsWith (substring As String, value As String, comparisonType As StringComparison, Optional message As String = "")
參數
- substring
- String
字串預期會是 的後綴 value。
- value
- String
預期以 結尾 substring的字串。
- comparisonType
- StringComparison
比較字串 comparisonType的方法。
- message
- String
當 包含在例外 value 中的訊息不以 substring結尾。 該訊息會顯示在測試結果中。
例外狀況
value 是空,或 substring 是空,或 value 不以 substring開頭。
適用於
EndsWith(String, String, String, String, String)
測試指定字串是否以指定後綴結尾,若測試字串未以該後綴結尾,則拋出例外。
public static void EndsWith(string? expectedSuffix, string? value, string? message = "", string expectedSuffixExpression = "", string valueExpression = "");
static member EndsWith : string * string * string * string * string -> unit
Public Shared Sub EndsWith (expectedSuffix As String, value As String, Optional message As String = "", Optional expectedSuffixExpression As String = "", Optional valueExpression As String = "")
參數
- expectedSuffix
- String
字串預期會是 的後綴 value。
- value
- String
預期以 結尾 expectedSuffix的字串。
- message
- String
當 包含在例外 value 中的訊息不以 expectedSuffix結尾。 該訊息會顯示在測試結果中。
- expectedSuffixExpression
- String
預期後綴的語法表達式,由編譯器透過呼叫者參數表達式給出。 使用者不應該傳遞這個參數的值。
- valueExpression
- String
由編譯器透過呼叫者參數表達式所給出的語法表達式。 使用者不應該傳遞這個參數的值。
例外狀況
value 是空,或 expectedSuffix 是空,或 value 不以 expectedSuffix開頭。