C# Easy
the c# snippets prefix is ( ! )
there is over 20 c# snippets
it has italic dark theme
visual studio icons
Features
!console
using System;
namespace ConsoleApp
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
!cclear
Console.Clear();
!log
Console.WriteLine("");
!cr
Console.ReadLine();
!classd
public class MyClass : IDisposable
{
public void Dispose()
{
GC.SuppressFinalize(this);
}
}
!immutable
public class ImmutableObject
{
private readonly string _name;
public string Name => _name
public ImmutableObject(string name)
{
_name = name;
}
}
!pum
public string Method(string parameter)
{
return System.NotImplementedException;
}
!pvm
public void Method(string parameter)
{
}
!singleton
public sealed class MyClass
{
private static volatile IMyObject instance;
private static Object syncRootObject = new Object();
public static IMyObject Instance
{
get
{
if (instance == null)
{
lock (syncRooObject)
{
if (instance == null)
{
instance = new MyObject();
}
}
}
return instance;
}
}
}
!singletonl
public sealed class MyClass : IMyObject
{
private static readonly Lazy<IMyObject> _instance = new Lazy<IMyObject>(() => new MyClass());
public static IMyObject Instance { get { return _instance.Value; } }
private MyClass()
{
}
}
!singletonts
public sealed class MyClass : IMyObject
{
private static readonly IMyObject _instance = new MyClass();
static MyClass() {}
private MyClass() {}
public static IMyObject Instance { get { return _instance; } }
}
!helloworld Startup
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace WebApp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
}
}
!helloworld WebApp
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace WebApp
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
}
!controller
namespace Name.Controllers
{
using Microsoft.AspNetCore.Mvc;
public class NameController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Welcome()
{
ViewData["Message"] = "Your welcome message";
return View();
}
}
}