Skip to content

Instantly share code, notes, and snippets.

View afsharm's full-sized avatar

afsharm

  • Turkey
View GitHub Profile
@richlander
richlander / csharp-read-only-auto-properties.cs
Created July 20, 2015 19:06
C# 6 Read-only Auto-Properties
public class Customer
{
public string First { get; } = "Jane";
public string Last { get; } = "Doe";
}
@richlander
richlander / csharp-nameof-operator.cs
Created July 20, 2015 17:57
C# 6 NameOf operator
if (x == null) throw new ArgumentNullException(nameof(x));
@richlander
richlander / csharp-null-conditional-operator.cs
Created July 20, 2015 17:56
Null-Conditional operator (?.)
int length = customers?.Length ?? 0; // 0 if customers is null
@richlander
richlander / csharp-string-interpolation.cs
Created July 20, 2015 17:52
C# 6 String Interpolation
var s = $"{p.Name} is {p.Age} year{{s}} old";
@richlander
richlander / csharp-multiline-string-literals.cs
Created July 20, 2015 17:47
C# Multiline String Literals
var s = @"Write your haiku with
No \r\n escapes
In C# v1";
@richlander
richlander / csharp-static-imports.cs
Created July 20, 2015 17:42
C# 6 Static Imports
using static System.Console;
using static System.Math;
using static System.DayOfWeek;
class Program
{
static void Main()
{
WriteLine(Sqrt(3 * 3 + 4 * 4));
WriteLine(Friday - Monday);
layout title description path
barewithrelated
Book Authoring Using GitHub and Git
Formats, tips and techniques for using GitHub and Git as the version control and collaborative platform for writing short and long form books.
usecases/_posts/2001-01-01-book-authoring-using-git-and-github.md

GitHub and Git are not just for writing programming code. They can also be an effective tool for writing articles and books. Matthew McCullough has written a quick guide to writing books in lightweight formats. This article will be folded into this Teaching repository over the coming months.

What is this?

@ebraminio
ebraminio / gist:5292017
Last active April 20, 2025 08:11
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, F#, Ruby, JavaScript, Dart, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir, PowerQuery M Language, VBA, R, Lua, Fortran, Pascal/Delphi, Excel, Stored Procedure / MySQL
// Check Iranian National Code Validity - Clojure, C#, F#, Ruby, JavaScript, Dart, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir, Power Query M Language, VBA, R, Lua, Fortran, Pascal/Delphi, Excel, Stored Procedure / MySQL
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، اف‌شارپ، روبی، جاوااسکریپت، دارت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو، سوئیفت، کاتلین، گرووی، راست، هسکل، ارلنگ، الکسیر، پاورکوئری ام، وی‌بی ای، آر، لوآ، فرترن، پاسکال/دلفی، اکسل، مای‌اس‌کیوال
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست https://web.archive.org/web/20170706081048/http://www.fardanews.com/fa/news/127747/رندترین-شماره-ملی-بلای-جان-صاحبش-شد
// بعضی از پیاده‌سازی‌ها سریع نیستند، می‌توانید نسخهٔ خود را بر پایهٔ
// نسخهٔ سی یا گو ایجاد کنید که بهترین سرعت را داشته باشد
/**
@skayred
skayred / asp-net-webapi.cs
Created October 17, 2012 07:56
Nancy and ASP.NET Web API comparison
namespace aspapi.Controllers
{
public class TaskApiController : ApiController
{
private readonly ITaskRepository taskRepository;
public TaskApiController()
{
taskRepository = new TaskRepository();
}