void PrintNum(NullableValueType number)
    {
        if (number == null)
        {
            Debug.Log("传入的数字为空值");
            return;
        }

        Debug.Log("传入的数字为:" + number.Value);
    }
Esempio n. 2
0
        public void NullableValueTypePropertyCanHandleNull()
        {
            var instance = new NullableValueType {
                Data = 1
            };

            var dataProperty = (IFullPropertyMetadata)PropertyMetadataHelper.GetPropertyMetadata <NullableValueType, int?>(x => x.Data);

            Assert.IsNotNull(dataProperty);
            Assert.DoesNotThrow(() => dataProperty.Setter(instance, null));
            Assert.IsNull(instance.Data);
        }
 // Use this for initialization
 void Start()
 {
     this.value = new NullableValueType(0f);
 }