Code indentation gets lost in Beamer

For any unknown reason I have to use verbatim instead of listings.

Note: This issue also appear when using listings but Herbert's answer can fix it. Unfortunately, the trick Herbert used there cannot be applied here. I attempted to use the same trick but it failed as follows.

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\begin{document}

\defverbatim[colored]
\Lst
{
\begin{verbatim}
class Foo
{
public static void Main()
{
Console.WriteLine("hello xport");
}
}
\end{verbatim}
}

\begin{frame}{hello xport}
\Lst
\end{frame}

\end{document}


It was compiled by pdflatex and latex->dvips->ps2pdf provided by TeX Live 2010 on Windows 7. And my editor is TeXnicCenter.

Caution:

If you want to try my code above, you must copy them in Edit mode. Copying the code directly from the rendered HTML will make my original tabs changed to spaces. :-)

-
I assume that beamer ignores all spaces outside frames by default. Maybe place the code inside the frame and the fragile option. –  Martin Scharrer Jul 16 '11 at 18:21
I tested it and I got indentation. –  Stefan Kottwitz Jul 16 '11 at 18:21
–  I am who I say I am Dec 11 '11 at 17:11
The \defverbatim ignores the tab character. Use instead spaces for the indentation or the package fancyvrb which can replace the tabs with a given number of spaces.