private CopyTo ( int sourceIndex, char destination, int destinationIndex, int count ) : void | ||
sourceIndex | int | |
destination | char | |
destinationIndex | int | |
count | int | |
return | void |
StringBuilder sb = new StringBuilder("Hello World"); char[] dest = new char[5]; sb.CopyTo(0, dest, 0, 5);
StringBuilder sb = new StringBuilder("Hello World"); char[] dest = new char[5]; sb.CopyTo(2, dest, 0, 5);In this example, we again create a new StringBuilder instance containing the string "Hello World". We also create a char array with 5 elements to serve as our destination array. However, this time we call the CopyTo method to copy a range of 5 characters starting from the index position 2 in the StringBuilder instance to the beginning of the char array. The package library for this class is the System.Text namespace, which is part of the .NET Framework Class Library.
private CopyTo ( int sourceIndex, char destination, int destinationIndex, int count ) : void | ||
sourceIndex | int | |
destination | char | |
destinationIndex | int | |
count | int | |
return | void |