using System; class Hoge { private string _helloWorld; private char _suffix = '!'; public string HelloWorld { get => _helloWorld; set => _helloWorld = value ?? throw new ArgumentNullException(); } public string TryGetHelloWorld(out string str) => str = (this.HelloWorld is string helloWorld) ? helloWorld : ""; public ref char GetSuffix() => ref _suffix; } class Program { public static void Main() { var hoge = new Hoge() { HelloWorld = "Hello World" }; var suffix = hoge.GetSuffix(); switch (hoge) { case object hogeObj: { ((Hoge)hogeObj).TryGetHelloWorld(out var helloWorld); Console.Write(helloWorld); Console.Write(suffix); break; } } } }