The C# module is one of the more recently added language modules to SWIG and consequently is missing some functionality available in some other SWIG modules. The C# module is very similar to the Java module, so until some documentation has been written, please use the Java documentation as a guide to using SWIG with C#. The rest of this chapter should be read in conjunction with the Java documentation as it lists the main differences.
Director support (virtual method callbacks into C#) has not yet been implemented and is the main missing feature compared to Java. The other missing feature is the lack of typemaps for wrapping STL code as well as a few minor utility typemaps in the various.i library.
Currently enums are wrapped with C# integers. Be warned that this will change in a forthcoming release. C# enums will be generated instead.
The most noteable differences to Java are the following:
jni -> ctype jtype -> imtype jstype -> cstype javain -> csin javaout -> csout javainterfaces -> csinterfaces javabase -> csbase javaclassmodifiers -> csclassmodifiers javacode -> cscode javaimports -> csimports javaptrconstructormodifiers -> csptrconstructormodifiers javagetcptr -> csgetcptr javafinalize -> csfinalize javadestruct -> csdestruct javadestruct_derived -> csdestruct_derived
csvarin C# code property set typemap csvarout C# code property get typemap
javaconst -> csconst javamethodmodifiers -> csmethodmodifiers
pragma(java) -> pragma(csharp) jniclassbase -> imclassbase jniclassclassmodifiers -> imclassclassmodifiers jniclasscode -> imclasscode jniclassimports -> imclassimports jniclassinterfaces -> imclassinterfaces
$javaclassname -> $csclassname $javainput -> $csinput $jnicall -> $imcall
The directory Examples/csharp has a number of simple examples. Visual Studio .NET 2003 solution and project files are available for compiling with the Microsoft .NET C# compiler on Windows. If your SWIG installation went well on a Unix environment and your C# compiler was detected, you should be able to type make in each example directory, then ilrun runme (Portable.NET C# compiler) or mono runme (Mono C# compiler) to run the examples. Windows users can also get the examples working using a Cygwin or MinGW environment for automatic configuration of the example makefiles. Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.