\newcommand throws error: Runaway Argument? Paragraph ended before \lstKV@OptArg@@ was complete

I'm using the listings package in a document. In order to simplify the use of the \lstinline command I created a new command that looks like this:

\newcommand{\lstcs}[1]{\lstinline[language=[Sharp]C,breaklines=false]#1}


And I've also tried:

\newcommand{\lstcs}[1]{\lstinline[language=[Sharp]C,breaklines=false]{#1}}


Obviously, I'm using this command to list C# code inline. This is my sample document where I get the exact same error message:

\documentclass{scrreprt}
\usepackage{listings}
\newcommand{\lstcs}[1]{\lstinline[language=[Sharp]C,breaklines=false]#1}

\begin{document}

This is \lstcs{CSharpCode()}.

\end{document}


The error message reads like this:

Runaway argument?
CSharpCode().
./test.tex:8: Paragraph ended before \lstKV@OptArg@@ was complete.
\par
l.8

?
[1{/usr/local/texlive/2012/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./test.aux) )
(\end occurred inside a group at level 1)

### simple group (level 1) entered at line 7 ({)
### bottom level
(\end occurred when \ifx on line 7 was incomplete)
(\end occurred when \ifx on line 7 was incomplete)
(\end occurred when \ifx on line 7 was incomplete)
(\end occurred when \ifx on line 7 was incomplete)
(\end occurred when \ifx on line 7 was incomplete) </usr/local/texlive/2012/texm
f-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on test.pdf (1 page, 11039 bytes).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.


I'm fairly new to LaTeX and I haven't used \newcommand before and I assume that's where the problem is.

I hope you can help me!

Thanks — Chris

-
The problem is [language=[. There you have the same delimiter [, so listings assumes that language= is the content – Tom Bombadil Aug 30 '12 at 11:54
That was it. Thanks a lot! – Christian Aug 30 '12 at 11:59

It gets confused when it sees the closing ] too early after Sharp so you need to enclose it with an adiitonal pair of braces. Also needs another pair of braces around #1

\documentclass{scrreprt}
\usepackage{listings}
\newcommand{\lstcs}[1]{\lstinline[language={[Sharp]C},breaklines=false]{#1}}

\begin{document}

This is \lstcs{CSharpCode()}.

\end{document}

-