a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
36 lines
669 B
C#
36 lines
669 B
C#
// Compiler options: -unsafe
|
|
|
|
using System;
|
|
|
|
class C
|
|
{
|
|
static unsafe void CopyTo (int sourceIndex, char[] destination, int destinationIndex, int count)
|
|
{
|
|
string s = "test string-";
|
|
fixed (char* dest = destination, src = s)
|
|
{
|
|
CharCopy (dest + destinationIndex, src + sourceIndex, count);
|
|
}
|
|
}
|
|
|
|
static unsafe void CharCopy (char *dest, char *src, int count)
|
|
{
|
|
for (int i = 0; i < count; i++) {
|
|
*dest++ = *src++;
|
|
}
|
|
}
|
|
|
|
public static int Main ()
|
|
{
|
|
CopyTo (5, null, 0, 0);
|
|
|
|
char[] output = new char [6];
|
|
CopyTo (5, output, 0, 6);
|
|
string s = new string (output);
|
|
Console.WriteLine (s);
|
|
if (s != "string")
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
} |