0
0
C Sharp (C#)programming~10 mins

Record structs in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a record struct named Point with two integer properties X and Y.

C Sharp (C#)
public [1] Point(int X, int Y);
Drag options to blanks, or click blank then click option'
Aclass
Bstruct
Crecord struct
Drecord class
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'class' or 'record class' instead of 'record struct'.
Using just 'struct' which is not a record struct.
2fill in blank
medium

Complete the code to create a new Point record struct instance with X=5 and Y=10.

C Sharp (C#)
var p = new Point([1], 10);
Drag options to blanks, or click blank then click option'
A5
BX
CY
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using the property name 'X' instead of the value 5.
Using 10 for the first parameter instead of the second.
3fill in blank
hard

Fix the error in the code to correctly compare two Point record structs for equality.

C Sharp (C#)
bool areEqual = p1 [1] p2;
Drag options to blanks, or click blank then click option'
Aequals
B==
C!=
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which is assignment, not comparison.
Using 'equals' which is not a valid operator in C#.
4fill in blank
hard

Fill both blanks to declare a record struct named Rectangle with properties Width and Height.

C Sharp (C#)
public [1] Rectangle(int [2], int Height);
Drag options to blanks, or click blank then click option'
Arecord struct
Bclass
CWidth
DHeight
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'class' instead of 'record struct'.
Using 'Height' instead of 'Width' for the first parameter.
5fill in blank
hard

Fill all three blanks to create a new Rectangle instance with Width=15 and Height=25, then check if Width is greater than 10.

C Sharp (C#)
var rect = new Rectangle([1], [2]);
bool isWide = rect.Width [3] 10;
Drag options to blanks, or click blank then click option'
A15
B25
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping Width and Height values.
Using '<' instead of '>' for the comparison.