CSharp · Console
using System;
object button = new RadioButton { Checked = true };
bool result = button switch
{
RadioButton radioButton => radioButton.Checked,
CheckButton checkButton => checkButton.Checked,
_ => throw new NullReferenceException()
};
Console.WriteLine(result);
class RadioButton
{
public bool Checked { get; set; }
}
class CheckButton
{
public bool Checked { get; set; }
}