Strings.Left(String, Int32) Yöntem
Tanım
Dizenin sol tarafından belirtilen sayıda karakter içeren bir dize döndürür.Returns a string containing a specified number of characters from the left side of a string.
public:
static System::String ^ Left(System::String ^ str, int Length);
public static string Left (string? str, int Length);
public static string Left (string str, int Length);
static member Left : string * int -> string
Public Function Left (str As String, Length As Integer) As String
Parametreler
- str
- String
Gereklidir.Required. String en soldaki karakterlerin döndürüldüğü ifade.String expression from which the leftmost characters are returned.
- Length
- Int32
Gereklidir.Required. Integer ifadesini.Integer expression. Kaç karakter dönebileceğinizi gösteren sayısal ifade.Numeric expression indicating how many characters to return. 0 ise, sıfır uzunluklu bir dize ("") döndürülür.If 0, a zero-length string ("") is returned. İçindeki karakter sayısından büyük veya ona eşitse str , tüm dize döndürülür.If greater than or equal to the number of characters in str, the entire string is returned.
Döndürülenler
Dizenin sol tarafından belirtilen sayıda karakter içeren bir dize.A string containing a specified number of characters from the left side of a string.
Özel durumlar
Length<0.Length < 0.
Örnekler
Bu örnek, Left belirli bir alt dizeyi döndürmek için işlevinin kullanımını gösterir String .This example demonstrates the use of the Left function to return a substring of a given String. Özelliği olan bir sınıfta Left , işlevi tamamen nitelendirmek gerekebilir Left .In a class that has a Left property, it may be necessary to fully qualify the Left function.
Dim testString As String = "Hello World!"
' Returns "Hello".
Dim subString As String = Left(testString, 5)
Açıklamalar
İçindeki karakter sayısını öğrenmek için str Len işlevini kullanın.To determine the number of characters in str, use the Len function. Bir Windows Forms uygulamasında veya özelliğine sahip başka bir sınıfta kullanılıyorsa, Left işlevi ile tam olarak nitelemeniz gerekir Microsoft.VisualBasic.Left .If used in a Windows Forms application, or any other class that has a Left property, you must fully qualify the function with Microsoft.VisualBasic.Left.
Not
LeftBVisual Basic önceki sürümlerindeki işlev, karakter yerine bayt cinsinden bir dize döndürür.The LeftB function in previous versions of Visual Basic returns a string in bytes rather than characters. Esas olarak çift baytlı karakter kümesi (DBCS) uygulamalarında dize dönüştürmek için kullanılır.It is used primarily for converting strings in double-byte character set (DBCS) applications. Tüm geçerli Visual Basic dizeleri Unicode ve LeftB artık desteklenmiyor.All current Visual Basic strings are in Unicode, and LeftB is no longer supported.