If you allow
for the usual 'public static main' stuff, the equivalent C# program
is also a one-liner, thanks to the using
statement. This
brings a whole namespace into global scope, so if there's a
using
System
;
at the top,
then any member of that namespace becomes directly available. It
would be very convenient to have this available for LuaInterface
programs as well. It turns out that this is not difficult at all,
using a short utility library:
require 'CLRPackage'
import "System"
Console.WriteLine("sqrt(2) is {0}",Math.Sqrt(2))
Here the
import
function works
very much like C#'s using
statement. This
program brings in the System.IO
namespace,
so now useful things like Directory
and
Path
effectively
become global.
require 'CLRPackage'
import "System"
import "System.IO"
Console.WriteLine("we are at {0}",Directory.GetCurrentDirectory())