Im experiencing some weird behaviour of some simple code i'm using to store a 2D position of an object.
I've created a class called SizeD containing a Width and Height as Double.
CODE:
public class SizeD
{
internal Double Width;
internal Double Height;
/// <summary>
/// Creates a new instance of SizeD
/// </summary>
public SizeD(Double Width, Double Height)
{
this.Width = Width; this.Height = Height;
return;
}
}
This is pretty straight foward and i didn't expect anything special to happen from this class.
There's also a static array with some of these predefined classes for easier use.
CODE:
internal static SizeD[] PaperTypeSize = //Converts CM to points.
{
new SizeD(8.5 * 72, 11.0 * 72),
new SizeD(8.5 * 72, 14.0 * 72),
new SizeD(21.0 * (72 / 2.54), 29.7 * (72 / 2.54))
};
The problem that i'm experiencing is that the value within the SizeD often Flip at runtime.
1: Width = Width and Height = Height.
2: Width = Height and Height = Width.
This also happens with a repeating pattern (1,2,1,2,1,2) and so on.
Can somone please explain to me what's happening here?
Thanks for your time!
EDIT: It happens mostly when trying to read this value SizeD(21.0 * (72 / 2.54), 29.7 * (72 / 2.54)).