# 15 SWIG and C#

The C# module has only recently been added to SWIG and is still in a state of development. 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 most noteable differences to Java are the following:

- When invoking SWIG use the `-csharp` command line option instead of `-java`.
- Typemap equivalent names:

  >     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

- Feature equivalent names:

  >     javaconst                   -> csconst
  >     javamethodmodifiers         -> csmethodmodifiers

- Pragma equivalent names:

  >     pragma(java)                -> pragma(csharp)
  >     jniclassbase                -> imclassbase
  >     jniclassclassmodifiers      -> imclassclassmodifiers
  >     jniclasscode                -> imclasscode
  >     jniclassimports             -> imclassimports
  >     jniclassinterfaces          -> imclassinterfaces

- Special variable equivalent names:

  >     $javaclassname              -> $csclassname
  >     $javainput                  -> $csinput
  >     $jnicall                    -> $imcall

An Additional special variable, $module, is replaced by the module name which is obtained from the `%module` directive or`-module` command line option.

Director support (callbacks into C#) have not yet been implemented.

The directory Examples/csharp has a number of examples. If your SWIG installation went well Unix users should be able to type `make` in each example directory, then `ilrun runme` (pnet C# compiler) or `mono runme` (Mono C# compiler). Windows users can also get the examples working but need a Cygwin or Mingw environment for automatic configuration of the example makefiles. Any one of the three C# compilers (pnet, mono or Microsoft) can be detected from within a Cygwin or MinGW environment. Some project files will be added soon for use with the Microsoft .NET C# compiler.