Page 180 - CSharp/C#
P. 180
Indexers
public object this[string key] => dictionary[key];
Is equivalent to:
public object this[string key]
{
get
{
return dictionary[key];
}
}
Methods
static int Multiply(int a, int b) => a * b;
Is equivalent to:
static int Multiply(int a, int b)
{
return a * b;
}
Which can also be used with void methods:
public void Dispose() => resource?.Dispose();
An override of ToString could be added to the Pair<T> class:
public override string ToString() => $"{First}, {Second}";
Additionally, this simplistic approach works with the override keyword:
public class Foo
{
public int Bar { get; }
public string override ToString() => $"Bar: {Bar}";
}
Operators
https://riptutorial.com/ 126

