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

unsafe-2.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: adedee296337a34e1290c4f20c6f6ca82e35fa5c (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
//
// This test excercises stackalloc, some pointer arithmetic,
// and dereferences
//
using System;
unsafe class X {
	static int Main ()
	{
		char *ptr = stackalloc char [10];
		int i;
		
		for (i = 0; i < 10; i++)
			ptr [i] = (char) (i + 10);

		for (i = 0; i < 10; i++){
			if (*ptr != (char) (i + 10))
				return 200 + i;
			ptr++;
		}
		Console.WriteLine ("Ok");
		return 0;
	}
}