Setting Padding - why it says padding.all is not variable?
Question
I do not understand why there is Control.padding.all which is int and according to hint there is set as well as get but I cannot set it (Control.Padding.All=5)? I would be grateful for explanation. Thanks!
Solution
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
OTHER TIPS
Control.Margin = new Padding(5)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow