String.TrimEnd Yöntem
Tanım
Aşırı Yüklemeler
| TrimEnd(Char[]) |
Geçerli dizeden bir dizide belirtilen bir karakter kümesinin tüm sondaki oluşumlarını kaldırır.Removes all the trailing occurrences of a set of characters specified in an array from the current string. |
| TrimEnd(Char) |
Geçerli dizeden bir karakterin tüm sonundaki oluşumlarını kaldırır.Removes all the trailing occurrences of a character from the current string. |
| TrimEnd() |
Geçerli dizeden tüm sondaki boşluk karakterlerini kaldırır.Removes all the trailing white-space characters from the current string. |
TrimEnd(Char[])
Geçerli dizeden bir dizide belirtilen bir karakter kümesinin tüm sondaki oluşumlarını kaldırır.Removes all the trailing occurrences of a set of characters specified in an array from the current string.
public:
System::String ^ TrimEnd(... cli::array <char> ^ trimChars);
public string TrimEnd (params char[] trimChars);
public string TrimEnd (params char[]? trimChars);
member this.TrimEnd : char[] -> string
Public Function TrimEnd (ParamArray trimChars As Char()) As String
Parametreler
- trimChars
- Char[]
Kaldırılacak Unicode karakter dizisi veya null .An array of Unicode characters to remove, or null.
Döndürülenler
Parametresindeki karakterlerin tüm oluşumları, geçerli dizenin sonundan kaldırıldıktan sonra kalan dize trimChars .The string that remains after all occurrences of the characters in the trimChars parameter are removed from the end of the current string. trimCharsİse null veya boş bir diziyse, bunun yerine Unicode boşluk karakterleri kaldırılır.If trimChars is null or an empty array, Unicode white-space characters are removed instead. Geçerli örnekten hiçbir karakter kırpılabilecek ise, yöntem geçerli örneği değişmeden döndürür.If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Örnekler
Aşağıdaki örnek, TrimEnd(System.Char[]) bir dizenin sonundaki boşluk veya noktalama işaretlerini kırpmak için yöntemini nasıl kullanabileceğinizi gösterir.The following example demonstrates how you can use the TrimEnd(System.Char[]) method to trim white space or punctuation marks from the end of a string.
string sentence = "The dog had a bone, a ball, and other toys.";
char[] charsToTrim = {',', '.', ' '};
string[] words = sentence.Split();
foreach (string word in words)
Console.WriteLine(word.TrimEnd(charsToTrim));
// The example displays the following output:
// The
// dog
// had
// a
// bone
// a
// ball
// and
// other
// toys
Module TrimEnd
Public Sub Main()
Dim sentence As String = "The dog had a bone, a ball, and other toys."
Dim charsToTrim() As Char = {","c, "."c, " "c}
Dim words() As String = sentence.Split()
For Each word As String In words
Console.WriteLine(word.TrimEnd(charsToTrim))
Next
End Sub
End Module
' The example displays the following output:
' The
' dog
' had
' a
' bone
' a
' ball
' and
' other
' toys
Açıklamalar
TrimEnd(System.Char[])Yöntemi, geçerli dizeden, parametresindeki sondaki tüm karakterleri kaldırır trimChars .The TrimEnd(System.Char[]) method removes from the current string all trailing characters that are in the trimChars parameter. Kırpma işlemi, içinde olmayan ilk karakter trimChars dizenin sonunda karşılaştığı zaman duraklar.The trim operation stops when the first character that is not in trimChars is encountered at the end of the string. Örneğin, geçerli dize "123abc456xyz789" ve trimChars "1" ile "9" arasındaki rakamları içeriyorsa, TrimEnd(System.Char[]) Yöntem "123abc456xyz" döndürür.For example, if the current string is "123abc456xyz789" and trimChars contains the digits from "1" through "9", the TrimEnd(System.Char[]) method returns "123abc456xyz".
Not
TrimEnd(System.Char[])Yöntem geçerli örnekten tüm karakterleri kaldırırsa, bu yöntem geçerli örneğin değerini değiştirmez.If the TrimEnd(System.Char[]) method removes any characters from the current instance, this method does not modify the value of the current instance. Bunun yerine, içinde bulunan tüm sondaki karakterlerin geçerli dizeden kaldırıldığı yeni bir dize döndürür trimChars .Instead, it returns a new string in which all trailing characters found in trimChars are removed from the current string.
Arayanlara Notlar
.NET Framework 3,5 SP1 ve önceki sürümleri, bu yöntemin bir trimChars veya boş dizi olarak kırpduğu boşluk karakterlerinin dahili bir listesini tutar null .The .NET Framework 3.5 SP1 and earlier versions maintains an internal list of white-space characters that this method trims if trimChars is null or an empty array. .NET Framework 4, trimChars null veya boş bir dizi ise, yöntemi tüm Unicode boşluk karakterlerini kırpar (diğer bir deyişle, true yönteme geçirildiğinde bir dönüş değeri üreten karakterler IsWhiteSpace(Char) ).Starting with the .NET Framework 4, if trimChars is null or an empty array, the method trims all Unicode white-space characters (that is, characters that produce a true return value when they are passed to the IsWhiteSpace(Char) method). Bu değişiklik nedeniyle, Trim() .NET Framework 3,5 SP1 ve önceki sürümlerindeki yöntem iki karakteri, sıfır GENIŞLIK alanını (u + 200B) ve sıfır GENIŞLIK yok (u + FEFF), Trim() .NET Framework 4 ve sonraki sürümlerindeki yöntemin KALDıRMADıĞı bir yere kaldırır.Because of this change, the Trim() method in the .NET Framework 3.5 SP1 and earlier versions removes two characters, ZERO WIDTH SPACE (U+200B) and ZERO WIDTH NO-BREAK SPACE (U+FEFF), that the Trim() method in the .NET Framework 4 and later versions does not remove. Ayrıca, Trim() .NET Framework 3,5 SP1 ve önceki sürümlerindeki Yöntem üç Unicode boşluk karakterini kırpmaz: Moğolca sesli harf ayırıcı (u + 180E), dar yok-kesme alanı (u + 202F) ve orta MATEMATIKSEL boşluk (u + 205F).In addition, the Trim() method in the .NET Framework 3.5 SP1 and earlier versions does not trim three Unicode white-space characters: MONGOLIAN VOWEL SEPARATOR (U+180E), NARROW NO-BREAK SPACE (U+202F), and MEDIUM MATHEMATICAL SPACE (U+205F).
Ayrıca bkz.
Şunlara uygulanır
TrimEnd(Char)
Geçerli dizeden bir karakterin tüm sonundaki oluşumlarını kaldırır.Removes all the trailing occurrences of a character from the current string.
public:
System::String ^ TrimEnd(char trimChar);
public string TrimEnd (char trimChar);
member this.TrimEnd : char -> string
Public Function TrimEnd (trimChar As Char) As String
Parametreler
- trimChar
- Char
Kaldırılacak Unicode karakteri.A Unicode character to remove.
Döndürülenler
Tüm karakter oluşumlarından sonra kalan dize, trimChar geçerli dizenin sonundan kaldırılır.The string that remains after all occurrences of the trimChar character are removed from the end of the current string. Geçerli örnekten hiçbir karakter kırpılabilecek ise, yöntem geçerli örneği değişmeden döndürür.If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Açıklamalar
TrimEnd(System.Char)Yöntemi geçerli dizeden sondaki tüm trimChar karakterleri kaldırır.The TrimEnd(System.Char) method removes from the current string all trailing trimChar characters. trimCharDizenin sonunda ilk karakter ile karşılaşılması durumunda trim işlemi durduruluyor.The trim operation stops when the first character that is not trimChar is encountered at the end of the string. Örneğin, trimChar - ve geçerli dize "---abc---xyz----" ise, TrimEnd(System.Char) Yöntem "---abc---xyz" değerini döndürür.For example, if trimChar is - and the current string is "---abc---xyz----", the TrimEnd(System.Char) method returns "---abc---xyz".
Not
TrimEnd(System.Char)Yöntem geçerli örnekten tüm karakterleri kaldırırsa, bu yöntem geçerli örneğin değerini değiştirmez.If the TrimEnd(System.Char) method removes any characters from the current instance, this method does not modify the value of the current instance. Bunun yerine, tüm sondaki trimChar karakterlerin geçerli dizeden kaldırıldığı yeni bir dize döndürür.Instead, it returns a new string in which all trailing trimChar characters are removed from the current string.
Şunlara uygulanır
TrimEnd()
Geçerli dizeden tüm sondaki boşluk karakterlerini kaldırır.Removes all the trailing white-space characters from the current string.
public:
System::String ^ TrimEnd();
public string TrimEnd ();
member this.TrimEnd : unit -> string
Public Function TrimEnd () As String
Döndürülenler
Tüm beyaz boşluk karakterleri geçerli dizenin sonundan kaldırıldıktan sonra kalan dize.The string that remains after all white-space characters are removed from the end of the current string. Geçerli örnekten hiçbir karakter kırpılabilecek ise, yöntem geçerli örneği değişmeden döndürür.If no characters can be trimmed from the current instance, the method returns the current instance unchanged.
Açıklamalar
TrimEndYöntemi, tüm sondaki boşluk karakterlerinden oluşan geçerli dizeden kaldırır.The TrimEnd method removes from the current string all trailing white-space characters. Dizenin sonunda ilk boşluk olmayan karakter ile karşılaşıldığında trim işlemi durduruluyor.The trim operation stops when the first non white-space character is encountered at the end of the string. Örneğin, geçerli dize "abc xyz" ise, TrimEnd Yöntem "abc xyz" döndürür.For example, if the current string is " abc xyz ", the TrimEnd method returns " abc xyz".
Not
TrimEndYöntem geçerli örnekten tüm karakterleri kaldırırsa, bu yöntem geçerli örneğin değerini değiştirmez.If the TrimEnd method removes any characters from the current instance, this method does not modify the value of the current instance. Bunun yerine, tüm sondaki boşluk karakterlerinin geçerli dizeden kaldırıldığı yeni bir dize döndürür.Instead, it returns a new string in which all trailing white-space characters are removed from the current string.