Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-709.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f5a5865995ce46c5ff446fa7de757e0e7ca86374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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;
	}
}