// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // Nullable - CastClass // Nullable type with castclass expr // // checking type of bool using cast expr // // // // using System.Runtime.InteropServices; using System; internal class NullableTest { private static bool BoxUnboxToNQ(T o) { return Helper.Compare((bool)(ValueType)(object)o, Helper.Create(default(bool))); } private static bool BoxUnboxToQ(T o) { return Helper.Compare((bool?)(ValueType)(object)o, Helper.Create(default(bool))); } private static int Main() { bool? s = Helper.Create(default(bool)); if (BoxUnboxToNQ(s) && BoxUnboxToQ(s)) return ExitCode.Passed; else return ExitCode.Failed; } }