System.ComponentModel.Tests.CustomDefaultValueAttribute.SetValue C# (CSharp) Method

SetValue() public method

public SetValue ( object value ) : void
value object
return void
        public new void SetValue(object value) => base.SetValue(value);
    }

Usage Example

Example #1
0
        public static void SetValue()
        {
            var attr = new CustomDefaultValueAttribute(null);

            attr.SetValue(true);
            Assert.Equal((object)true, attr.Value);

            attr.SetValue(false);
            Assert.Equal((object)false, attr.Value);

            attr.SetValue(12.8f);
            Assert.Equal(12.8f, attr.Value);

            attr.SetValue(12.8);
            Assert.Equal(12.8, attr.Value);

            attr.SetValue((byte)1);
            Assert.Equal((byte)1, attr.Value);

            attr.SetValue(28);
            Assert.Equal(28, attr.Value);

            attr.SetValue(TimeSpan.FromHours(1));
            Assert.Equal(TimeSpan.FromHours(1), attr.Value);

            attr.SetValue(null);
            Assert.Null(attr.Value);
        }
All Usage Examples Of System.ComponentModel.Tests.CustomDefaultValueAttribute::SetValue
CustomDefaultValueAttribute