To be honest, I am looking for people who already read the listings documentation completely. If those people also cannot solve it, then the documentation does not mention anything about it. Sorry for this inconvenience.
But at least I can show my effort by providing you with the minimal working example.
\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{Program.cs}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Delegate
{
class Program
{
// start
static void Main(string[] args)
{
for (int x = 0; x < 10; x++)
Console.WriteLine(x);
}
// stop
}
}
\end{filecontents*}
\usepackage{accsupp}
\newcommand*{\noaccsupp}[1]{\BeginAccSupp{ActualText={}}#1\EndAccSupp{}}
\usepackage{xcolor}
\usepackage{listings}
\lstdefinestyle{Common}
{
language={[Sharp]C},
numbers=left,
numbersep=1em,
numberstyle=\tiny\noaccsupp,
frame=single,
framesep=\fboxsep,
framerule=\fboxrule,
rulecolor=\color{red},
xleftmargin=\dimexpr\fboxsep+\fboxrule,
xrightmargin=\dimexpr\fboxsep+\fboxrule,
breaklines=true,
breakindent=0pt,
tabsize=2,
columns=flexible,
includerangemarker=false,
rangeprefix=//\ ,
}
\lstdefinestyle{A}
{
style=Common,
backgroundcolor=\color{yellow!10},
basicstyle=\scriptsize\ttfamily,
keywordstyle=\color{blue}\bf,
identifierstyle=\color{black},
stringstyle=\color{red},
commentstyle=\color{green}
}
\begin{document}
\section*{Full Code}
\lstinputlisting[style=A]{Program.cs}
\section*{Code Snippet}
\lstinputlisting[style=A,linerange=start-stop]{Program.cs}
\end{document}*

My question is how to remove the leading white space when using linerange option?
Edit
Consider some extreme cases below.
Case 1
namespace Delegate
{
class Program
{
// start
static void Main(string[] args)
{
for (int x = 0; x < 10; x++)
Console.WriteLine(x);
}
}
}
// stop
The code should be rendered as follows
with includrangemarker=true
// start
static void Main(string[] args)
{
for (int x = 0; x < 10; x++)
Console.WriteLine(x);
}
}
}
// stop
with includerangemarker=false
static void Main(string[] args)
{
for (int x = 0; x < 10; x++)
Console.WriteLine(x);
}
}
}
Case 2
namespace Delegate
{
class Program
{
// start
static void Main(string[] args)
{
for (int x = 0; x < 10; x++)
Console.WriteLine(x);
}
}
}
// stop
The code should be rendered as follows
with includerangemarker=true,
// start
static void Main(string[] args)
{
for (int x = 0; x < 10; x++)
Console.WriteLine(x);
}
}
}
// stop
with includerangermarker=false
static void Main(string[] args)
{
for (int x = 0; x < 10; x++)
Console.WriteLine(x);
}
}
}

gobbleoption and theautogobblefromlstautogobblepackage have no effect with\lstinputlisting... – karlkoeller Dec 24 '13 at 16:21framexleftmargin=-16pt,numbersep=-8pt,xleftmargin=-18ptis used to revert the indentation." So it's not automatic and it's probably more elegant to use multiples of the char width used in the code, but I can see how this could probably be made relatively comfortable. Maybe I'll try that as soon as some time comes along. – Christian Jan 13 '14 at 14:46$p– jub0bs Feb 07 '14 at 19:24// startmarker. – jub0bs Mar 14 '14 at 16:57//Startas a reference provides us with more control because we can specify the position of//Startfreely. – kiss my armpit Mar 14 '14 at 17:00listingsmakes the implementation of such a feature very tricky. I don't know how to implement it. Sorry. The best I can do is what I wrote in my earlier comment. – jub0bs Mar 14 '14 at 17:07