2003-09-24 Bernie Solomon <bernard@ugsolutions.com>
[mono.git] / mono / tests / pinvoke9.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 public class Test {
5
6         [DllImport ("libtest", EntryPoint="mono_test_return_string")]
7         public static extern String mono_test_return_string (ReturnStringDelegate d);
8
9         public static String managed_return_string (String s) {
10
11                 Console.WriteLine ("delegate called: " + s);
12                 if (s != "TEST")
13                         return "";
14                 else
15                         return "12345";
16         }
17
18         public delegate String ReturnStringDelegate (String s);
19
20         public static int Main () {
21                 ReturnStringDelegate d = new ReturnStringDelegate (managed_return_string);
22                 String s = mono_test_return_string (d);
23
24                 Console.WriteLine ("Received: " + s);
25
26                 if (s == "12345")
27                         return 0;
28                 
29                 return 1;
30         }
31 }