本文整理匯總了C#中System.Char.CopyTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Char.CopyTo方法的具體用法?C# Char.CopyTo怎麽用?C# Char.CopyTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Char
的用法示例。
在下文中一共展示了Char.CopyTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestCopyTo
public void TestCopyTo() {
{
bool errorThrown = false;
try {
Char[] c1 = new Char[2];
c1.CopyTo(null, 2);
} catch (ArgumentNullException) {
errorThrown = true;
}
Assert("#E61", errorThrown);
}
{
bool errorThrown = false;
try {
Char[] c1 = new Char[2];
Char[,] c2 = new Char[2,2];
c1.CopyTo(c2, 2);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#E62", errorThrown);
}
{
bool errorThrown = false;
try {
Char[,] c1 = new Char[2,2];
Char[] c2 = new Char[2];
c1.CopyTo(c2, -1);
} catch (RankException) {
errorThrown = true;
}
Assert("#E63", errorThrown);
}
{
bool errorThrown = false;
try {
Char[,] c1 = new Char[2,2];
Char[] c2 = new Char[2];
c1.CopyTo(c2, 2);
} catch (RankException) {
errorThrown = true;
}
Assert("#E64", errorThrown);
}
{
bool errorThrown = false;
try {
Char[] c1 = new Char[2];
Char[] c2 = new Char[2];
c1.CopyTo(c2, -1);
} catch (ArgumentOutOfRangeException) {
errorThrown = true;
}
Assert("#E65", errorThrown);
}
{
bool errorThrown = false;
try {
Char[] c1 = new Char[2];
Char[] c2 = new Char[2];
c1.CopyTo(c2, 3);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#E66", errorThrown);
}
{
bool errorThrown = false;
try {
Char[] c1 = new Char[2];
Char[] c2 = new Char[2];
c1.CopyTo(c2, 1);
} catch (ArgumentException) {
errorThrown = true;
}
Assert("#E67", errorThrown);
}
{
bool errorThrown = false;
try {
String[] c1 = new String[2];
// TODO: this crashes mono if there are null
// values in the array.
c1[1] = "hey";
c1[0] = "you";
Char[] c2 = new Char[2];
c2[1] = 'a';
c2[0] = 'z';
c1.CopyTo(c2, 0);
} catch (ArrayTypeMismatchException) {
errorThrown = true;
}
Assert("#E68", errorThrown);
}
Char[] orig = {'a', 'b', 'c', 'd'};
Char[] copy = new Char[10];
Array.Clear(copy, 0, copy.Length);
orig.CopyTo(copy, 3);
//.........這裏部分代碼省略.........