Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Nagel christiannagel

View GitHub Profile
View CS6ReadOnlyProp.cs
public class Gadget
{
public Gadget(int id, string name)
{
this.Id = id;
this.Name = name;
}
public int Id { get; }
public string Name { get; }
View CS5ReadOnlyProp.cs
public class Gadget
{
public Gadget(int id, string name)
{
this.id = id;
this.name = name;
}
private readonly int id;
public int Id
@christiannagel
christiannagel / CS5AutoProp.cs
Last active Aug 29, 2015
C# 5 Property Initializer
View CS5AutoProp.cs
public class Sample1
{
public Sample1()
{
IsTrue = true;
}
public bool IsTrue { get; set; }
}
@christiannagel
christiannagel / CS6AutoProp.cs
Last active Aug 29, 2015
C# 6 Property Initializer
View CS6AutoProp.cs
public class Sample1
{
public bool IsTrue { get; set; } = true;
}
@christiannagel
christiannagel / HelloWorld.cs
Created Jun 20, 2015
Hello, World with C# 6
View HelloWorld.cs
using static System.Console;
class Program
{
public void Main()
{
WriteLine("Hello, World!");
}
}
View Lambdas.cpp
[] {
std::cout << "hello, lambda" << std::endl;
}();
@christiannagel
christiannagel / Program.cs
Created Apr 5, 2013
C# simple lambda expression
View Program.cs
Action l1 = () => Console.WriteLine("Hello, Lambda!");
l1();
@christiannagel
christiannagel / Lambdas.cpp
Created Apr 5, 2013
C++11 lambda no return no parameter
View Lambdas.cpp
auto l1 = [] {
std::cout << "hello, lambda" << std::endl;
};
l1();
@christiannagel
christiannagel / Program.cs
Created Apr 5, 2013
C# Lambda - returning a value
View Program.cs
Func<int> l2 = () => 42;
int x2 = l2();
You can’t perform that action at this time.