raddevus wrote:
If you don't have the deconstructor in your class and you try the destructuring you will get an error
Unless you have a deconstructor extension method, which can be handy for third-party classes that don't provide them:
// In your "SimpleShapes.dll" assembly:
public class Rectangle(float width, float height)
{
public readonly float Width = width, Height = height;
}
// In my application code:
public static class Shapes
{
public static void Deconstruct (this Rectangle rectangle, out float width, out float height)
=> (width, height) = (rectangle.Width, rectangle.Height);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer