Point Move(int dx, int dy) => new Point(x + dx, y + dy); public static Complex operator +(Complex a, Complex b) => a.Add(b); public static implicit operator string (Person p) => p.First + " " + p.Last; C# 6
The type, not the namespace class Program { static void Main() { var range = Range(5, 17); // Ok: not extension var odd = Where(range, i => i % 2 == 1); // Error, not in scope var even = range.Where(i => i % 2 == 0); // Ok } } C# 6
// null if people is null Person first = people?[0]; // null if people is null int length = people?.Length ?? 0; // 0 if people is null int? firstCount = people?[0].Orders.Count(); C# 6
abstract class FormattableString : IFormattable { protected FormattableString(); public abstract int ArgumentCount { get; } public abstract string Format { get; } public static string Invariant(FormattableString formattable); public abstract object GetArgument(int index); public abstract object[] GetArguments(); public override string ToString(); public abstract string ToString(IFormatProvider formatProvider); } C# 6