0

Recently I saw a strange syntax of property

public bool IsEnabled => control.IsEnabled;

Question: How this thing is called? I've failed to find a proper name for it and therefore can't find it to read about it.


Some tests proves it behaves as a property without setter:

bool TestA { get; set; }
bool TestB => TestA;

TestA = false;
Console.WriteLine(TestA); // false
Console.WriteLine(TestB); // false
TestA = true;
Console.WriteLine(TestA); // true
Console.WriteLine(TestB); // true

Console.WriteLine(this.GetType().GetProperty(nameof(TestB),
    BindingFlags.NonPublic | BindingFlags.Instance)?.CanWrite); // false
Sinatr
  • 19,902
  • 11
  • 86
  • 275

0 Answers0