裏口からのC#実践入門
4-5 冗長な判定
as と is の動作を確認。
as (C# リファレンス)
is (C# リファレンス)
using System; namespace Uraguchi.Scene4 { public class Tenshi5 { public static void Run() { object a = "Hello"; if (a is string) { var b = a as string; Console.WriteLine(b); } } } }