Next: , Previous: Using pragma foreign_export for C#, Up: Interfacing with C#   [Contents] Using pragma foreign_decl for C#

pragma foreign_decl’ declarations for C# can be used to provide any top-level C# declarations (e.g. ‘using’ declarations or auxiliary class definitions) which are needed by C# code in ‘pragma foreign_proc’ declarations in that module.

For example:

:- pragma foreign_decl("C#", "
	using System;
:- pred hello(io.state::di, io.state::uo) is det.
:- pragma foreign_proc("C#",
     hello(_IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure],
    // here we can refer directly to Console rather than System.Console
    Console.WriteLine(""hello world"");