c# - How to simplify my code? (Searching for minimum and maximum coordinates in list of lines) -
I have a code that is searching for the minimum and maximum values in the list of rows, I need it to be rectangular center Which is bound to my complex diagram.
My part of the code looks like this:
if (line.X1
I do not like this ugly copy-paste code. How can I make it simpler / make it more elegant?
Looking at the following populated variables:
from the list & Lt; Line & gt; Lines;
Obtain X values and Y values:
var xValues = rows Select (line = & gt; new [] {line.X1, Line X2}); Var yValues = Lines Select (line = & gt; new [] {line.Y1, line.Y2});
Then get the minimum and maximum of each:
var at least x = xValues.Min (); Var greatX = xValues.Max (); Var at least Y = yValues.Min (); Var great y = yValues.Max ();
Note that this code has not been tested.
Comments
Post a Comment