本文整理汇总了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);
//.........这里部分代码省略.........