Strings.StrReverse(String) 方法

定義

傳回字串,此字串會反轉指定字串中的文字元素順序。

public:
 static System::String ^ StrReverse(System::String ^ Expression);
public static string StrReverse (string? Expression);
public static string StrReverse (string Expression);
static member StrReverse : string -> string
Public Function StrReverse (Expression As String) As String

參數

Expression
String

必要。 要反轉其文字元素的字串表達式。 如果 Expression 是長度為零的字串 (""),則會傳回長度為零的字串。

傳回

字串,會反轉指定字串中的文字元素順序。

範例

Dim testString As String = "ABCDEFG"
' Returns "GFEDCBA".
Dim revString As String = StrReverse(testString)

備註

函式會 StrReverse 傳回字串,其中包含與 相同的文字元素 Expression,但順序相反。 文字元素做為單一字元顯示的文字單位,也就是 grapheme。

例如,假設字串 “re\u0301sume\u0301”,其中 '\u0301' 是結合 ACCENT ACCENT 的代碼點 U+0301。 向用戶顯示時,此字串會顯示為字組 résumé ,並正確放置於 『e' 字元上。 如果文字 résumé 是以字元反轉字元,則產生的字串會是 ́emuśer,其中一個輔色超過錯誤的字元。 相反地, StrReverse 將輸入字串分割成個別的文字元素,讓每個文字元素保持不變,但交換結果字串內每個文字元素的位置。

For more information about how .NET divides a string instance into text elements, see the Remarks section for the StringInfo class.

適用於

另請參閱