Complete the code to declare a readonly struct named Point.
public [1] struct Point { public int X; public int Y; }The readonly keyword makes the struct immutable after creation.
Complete the code to create a readonly property in the readonly struct.
public readonly struct Rectangle { public int Width { [1]; } }Readonly properties in readonly structs only have a get accessor.
Fix the error in the readonly struct method that tries to modify a field.
public readonly struct Circle { public int Radius; public void SetRadius(int r) { [1] = r; } }In a readonly struct, to modify a field inside a method, you must use this explicitly, but modification is not allowed; the method should be removed or the struct not readonly.
Fill both blanks to create a readonly struct with a constructor initializing its fields.
public [1] struct Vector2D { public int X; public int Y; public [2] Vector2D(int x, int y) { X = x; Y = y; } }
The struct must be declared readonly and the constructor has the same name as the struct.
Fill all three blanks to create a readonly struct with a method that returns the distance from origin.
public [1] struct Point3D { public int X; public int Y; public int Z; public double [2]() { return Math.[3](X * X + Y * Y + Z * Z); } }
The struct is readonly, the method is named DistanceFromOrigin, and it uses Math.Sqrt to calculate distance.