2 using System.Runtime.CompilerServices;
3 using System.Runtime.InteropServices;
4 using System.Collections;
6 using System.Threading;
12 [MethodImplAttribute (MethodImplOptions.InternalCall)]
13 public extern static void my_c_func(int x, string s, double d);
14 [MethodImplAttribute (MethodImplOptions.InternalCall)]
15 public extern static void my_c_pass(int x);
18 public class HelloWorld
20 static public void Main ()
24 static public void Foobar (int x, string s)
26 // first line is a simple test
27 // 1. call back into c code 2. use mscorlib Math.Sqrt()
28 c_code.my_c_func(x, s, Math.Sqrt(3.1415 * 3.1415));
30 // second part of this test:
31 // attempt a try/catch, generate exception w/ throw
34 // attempt an invalid cast
35 throw new InvalidCastException();
38 catch (InvalidCastException e) {
43 // third part of this test:
44 // attempt an invalid cast again, this time generating
45 // exception instead of using explicit throw.
48 StringBuilder reference1 = new StringBuilder();
49 object reference2 = reference1;
50 // attempt invalid cast
51 int reference3 = (int)reference2;
54 catch (InvalidCastException e) {