Hi, 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!
Yeah I know how to get it work..I just do not understand why there is Padding.all or left or whatever...but cannot be set as a int.
Petr
2009-11-26 08:19:11
A:
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
Ahmadreza
2009-11-26 08:33:31
I've just submitted a post about this issue in my blog: http://ahmadreza.com/blog/post/Value-type-property-and-C-compilation-error.aspx
Ahmadreza
2009-12-10 21:34:58