开发者

Setting Padding - why it says padding.all is not variable?

I do not understand why there is Control.padding.all which is int and according to hint there is set as well as get b开发者_StackOverflow中文版ut I cannot set it (Control.Padding.All=5)? I would be grateful for explanation. Thanks!


Control.Margin = new Padding(5)


Here is a simple Implementation of this

public class ARAControl
{
    public ARAPadding Padding { get; set; }
}
public struct ARAPadding

{
    public int All { get; set; }
}

And if you use this you probably get this error

        ARAControl control = new ARAControl();
        control.Padding.All = 10;

It hapens because structure is a value type. By setting this property you first call get Method. Property Get will return a copy of Padding so it is a value type and C# will detect out mistake and prevent compiling

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜