Skip to content

Instantly share code, notes, and snippets.

View christiannagel's full-sized avatar
💭
working on the new book Pragmatic Microservices with C# and Azure

Christian Nagel christiannagel

💭
working on the new book Pragmatic Microservices with C# and Azure
View GitHub Profile
@christiannagel
christiannagel / CS5AutoProp.cs
Last active August 29, 2015 14:10
C# 5 Property Initializer
public class Sample1
{
public Sample1()
{
IsTrue = true;
}
public bool IsTrue { get; set; }
}
@christiannagel
christiannagel / CS6AutoProp.cs
Last active August 29, 2015 14:10
C# 6 Property Initializer
public class Sample1
{
public bool IsTrue { get; set; } = true;
}
public class Gadget
{
public Gadget(int id, string name)
{
this.Id = id;
this.Name = name;
}
public int Id { get; }
public string Name { get; }
public class Gadget
{
public Gadget(int id, string name)
{
this.id = id;
this.name = name;
}
private readonly int id;
public int Id
@christiannagel
christiannagel / HelloWorld.cs
Created June 20, 2015 14:35
Hello, World with C# 6
using static System.Console;
class Program
{
public void Main()
{
WriteLine("Hello, World!");
}
}
@christiannagel
christiannagel / Lambdas.cpp
Created April 5, 2013 08:09
C++11 Lambda 1
[] {
std::cout << "hello, lambda" << std::endl;
}();
@christiannagel
christiannagel / Program.cs
Created April 5, 2013 15:01
C# simple lambda expression
Action l1 = () => Console.WriteLine("Hello, Lambda!");
l1();
@christiannagel
christiannagel / Lambdas.cpp
Created April 5, 2013 15:35
C++11 lambda no return no parameter
auto l1 = [] {
std::cout << "hello, lambda" << std::endl;
};
l1();
@christiannagel
christiannagel / Program.cs
Created April 5, 2013 16:03
C# Lambda - returning a value
Func<int> l2 = () => 42;
int x2 = l2();