I recently had to write a report using LaTeX. I had a problem with inserting my code snippets into the report. Online I found many advanced ways of doing this. With code highlighting and other effects. All I wanted was a simple way to add my snippets. Since I am just writing a report the below will suffice. The solution was to use verbatim in LaTeX:

\begin{verbatim}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}

\end{verbatim}

Know an easier way? let me know!