Strings.Right(String, Int32) Metoda
Definice
Vrátí řetězec obsahující zadaný počet znaků z pravé strany řetězce.Returns a string containing a specified number of characters from the right side of a string.
public:
static System::String ^ Right(System::String ^ str, int Length);
public static string Right (string? str, int Length);
public static string Right (string str, int Length);
static member Right : string * int -> string
Public Function Right (str As String, Length As Integer) As String
Parametry
- str
- String
Povinná hodnota.Required. String výraz, ze kterého jsou vraceny znaky zprava vpravoString expression from which the rightmost characters are returned.
- Length
- Int32
Povinná hodnota.Required. Integer.Integer. Číselný výraz označující, kolik znaků se má vrátit.Numeric expression indicating how many characters to return. Pokud je nastaveno na hodnotu 0, je vrácen řetězec s nulovou délkou ("").If 0, a zero-length string ("") is returned. Pokud je větší nebo rovno počtu znaků v str , vrátí se celý řetězec.If greater than or equal to the number of characters in str, the entire string is returned.
Návraty
Řetězec obsahující zadaný počet znaků od pravé strany řetězce.A string containing a specified number of characters from the right side of a string.
Výjimky
Length<0.Length < 0.
Příklady
Tento příklad ukazuje použití Right funkce k vrácení podřetězce daného String .This example demonstrates the use of the Right function to return a substring of a given String. Ve třídě, která má Right vlastnost, může být nutné plně kvalifikovat Right funkci.In a class that has a Right property, it may be necessary to fully qualify the Right function.
Dim testString As String = "Hello World!"
' Returns "World!".
Dim subString As String = Right(testString, 6)
Poznámky
Chcete-li určit počet znaků v str , použijte Len funkci.To determine the number of characters in str, use the Len function. Pokud se používá ve formuláři Windows nebo jakékoli jiné třídě, která má Right vlastnost, musíte funkci plně kvalifikovat pomocí Microsoft.VisualBasic.Strings.Right .If used in a Windows Form, or any other class that has a Right property, you must fully qualify the function with Microsoft.VisualBasic.Strings.Right.
Poznámka
RightBFunkce v dřívějších verzích Visual Basic vrátí řetězec v bajtech namísto znaků.The RightB function in earlier versions of Visual Basic returns a string in bytes, rather than characters. Používá se především pro převod řetězců v aplikacích dvoubajtové znakové sady (DBCS).It is used primarily for converting strings in double-byte character set (DBCS) applications. Všechny aktuální Visual Basic řetězce jsou v kódování Unicode a RightB již nejsou podporovány.All current Visual Basic strings are in Unicode, and RightB is no longer supported.