I would like to shorten the expression like
this.GdkWindow.GetPosition(ConfigurationService.ApplicationSettings.rect1.X, ConfigurationService.ApplicationSettings.rect1.Y);
to something like this.GdkWindow.GetPosition(refRect1.X, refRect1.Y) , using the link to the ConfigurationService.ApplicationSettings.rect1 variable.
In C ++, I can use a reference to an object (or variable) as follows:
Rect& refRect1 = very.very2.very3.long_variable.rect1; GetPosition(refRect1.x, refRect1.y);
How can I do the same in C #?
And how can I make a reference to an int variable, as the following C ++ code does:
int A = 5; int& B = A; B = 12;
Update: The GetPosition method GetPosition declared as void GetPosition(out int x, out int y) . This method populates the ConfigurationService.ApplicationSettings.rect1 structure with some data. That is why I would like to use the link.
I know I can do something like:
var rect = new Gdk.Rectangle(); this.GdkWindow.GetPosition(out rect.X, out rect.Y); this.GdkWindow.GetSize(out rect.Width, out rect.Height); ConfigurationService.ApplicationSettings.rect1 = rect;
but is there a way to avoid using a temporary variable? Is C # a lack of function even PHP? Absolutely disappointed in C #!
source share