StringBuilder.ToString Metodo
Definizione
Converte il valore di un oggetto StringBuilder in un oggetto String.Converts the value of a StringBuilder to a String.
Overload
ToString() |
Converte il valore di questa istanza in un oggetto String.Converts the value of this instance to a String. |
ToString(Int32, Int32) |
Converte il valore di una sottostringa di questa istanza in un oggetto String.Converts the value of a substring of this instance to a String. |
ToString()
Converte il valore di questa istanza in un oggetto String.Converts the value of this instance to a String.
public:
override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
Restituisce
Stringa il cui valore è lo stesso di questa istanza.A string whose value is the same as this instance.
Esempi
Nel codice riportato di seguito viene illustrata la chiamata al metodo ToString.The following example demonstrates calling the ToString method. Questo esempio fa parte di un esempio più ampio fornito per la classe StringBuilder.This example is part of a larger example provided for the StringBuilder class.
// Display the number of characters in the StringBuilder
// and its string.
Console::WriteLine("{0} chars: {1}", sb->Length, sb->ToString());
// Display the number of characters in the StringBuilder and its string.
Console.WriteLine("{0} chars: {1}", sb.Length, sb.ToString());
' Display the number of characters in the StringBuilder and its string.
Console.WriteLine("{0} chars: {1}", sb.Length, sb.ToString())
Commenti
È necessario chiamare il metodo ToString per convertire l'oggetto StringBuilder in un oggetto String prima di poter passare la stringa rappresentata dall'oggetto StringBuilder a un metodo con un parametro String o visualizzarlo nell'interfaccia utente.You must call the ToString method to convert the StringBuilder object to a String object before you can pass the string represented by the StringBuilder object to a method that has a String parameter or display it in the user interface.
ToString(Int32, Int32)
Converte il valore di una sottostringa di questa istanza in un oggetto String.Converts the value of a substring of this instance to a String.
public:
System::String ^ ToString(int startIndex, int length);
public string ToString (int startIndex, int length);
override this.ToString : int * int -> string
Public Function ToString (startIndex As Integer, length As Integer) As String
Parametri
- startIndex
- Int32
Posizione iniziale della sottostringa in questa istanza.The starting position of the substring in this instance.
- length
- Int32
Lunghezza della sottostringa.The length of the substring.
Restituisce
Stringa il cui valore è lo stesso della sottostringa specificata di questa istanza.A string whose value is the same as the specified substring of this instance.
Eccezioni
startIndex
o length
è minore di zero.startIndex
or length
is less than zero.
-oppure--or-
La somma di startIndex
e length
è maggiore della lunghezza dell'istanza corrente.The sum of startIndex
and length
is greater than the length of the current instance.
Commenti
È necessario chiamare il metodo ToString per convertire l'oggetto StringBuilder in un oggetto String prima di poter passare la stringa rappresentata dall'oggetto StringBuilder a un metodo con un parametro String o visualizzarlo nell'interfaccia utente.You must call the ToString method to convert the StringBuilder object to a String object before you can pass the string represented by the StringBuilder object to a method that has a String parameter or display it in the user interface.