A few good ideas from Kotlin


#1
  • primary constructors - public class Point(int x, int y) { }
  • read only auto-properties - public int X { get; } = x;
  • static type using statements - using System.Math;
  • property expressions -public double Distance => Sqrt(X * X + Y * Y);
  • method expressions -public Point Move(int dx, int dy) => new Point(X + dx, Y + dy);
  • params for enumerables -public Point Average(params IEnumerable<Point> points) { }
  • monadic null checking - if (points?.FirstOrDefault()?.X ?? -1) { }
  • constructor type parameter inference -var t = new Tuple(1,2); // infers Tuple<T1, T2>
  • inline declarations for out params -public void Foo(out var x, out var y) { }

(http://adamralph.com/2013/12/06/ndc-diary-day-3/?1)

Above is a list of features considered/planned for next version of C#. Interesting.