Assign values on multi-properties to a object

Posted by Lu Lu on Stack Overflow See other posts from Stack Overflow or by Lu Lu
Published on 2012-06-05T04:16:41Z Indexed on 2012/06/05 4:40 UTC
Read the original article Hit count: 194

Filed under:
|

I have a object which it was initialized before in a base class. In inherited class, I use this object and assign values on multi-properties to it. Example:

this.Chart.X = 10;
this.Chart.Y = 10;
this.Chart.Width = 20;
this.Chart.Height = 20;
this.Chart.Background = Color.Red;

However, I must repeat "this.Chart" many times. How to avoid this. Note that I don't want to re-create this object again because in the base class, it was initialized with some common values.

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET