[Tex/LaTex] Listings package for C#

listings

I intend to use the package listings for including C# code in a LaTeX document. There are a lot of languages supported by this package, but C# lacks at all. Is there an extension for adding support for this language? or where should I add the C# (ver 4.0) keywords to see them highlighted? Note that the support for Java/C++ does not suffice, as there are some keywords not introduced in these languages: ref, out, var etc.

Best Answer

The listings package supports it (see the manual, page 12). Your document could look something like this:

\documentclass{scrartcl}
\usepackage{listings}
\usepackage{xcolor}

\lstdefinestyle{sharpc}{language=[Sharp]C, frame=lr, rulecolor=\color{blue!80!black}}

\begin{document}

\lstset{style=sharpc}
\begin{lstlisting}
Your c# code here
\end{lstlisting}

\end{document}

As I don't know C#, I also don't know if the language definition of listings is sufficient for you, but it offers morekeywords key, so you can add the ones you are missing