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

Auto-implemented properties 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 an auto-implemented property named Name of type string.

C Sharp (C#)
public class Person {
    public string [1] { get; set; }
}
Drag options to blanks, or click blank then click option'
AName
Bname
CFullName
DGetName
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase property names like 'name' instead of 'Name'.
Using method-like names such as 'GetName'.
2fill in blank
medium

Complete the code to declare an auto-implemented property named Age of type int.

C Sharp (C#)
public class Person {
    public [1] Age { get; set; }
}
Drag options to blanks, or click blank then click option'
Astring
Bbool
Cdouble
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using string or bool for age.
Using floating point types like double.
3fill in blank
hard

Fix the error in the auto-implemented property declaration by completing the code.

C Sharp (C#)
public class Product {
    public decimal [1] { get; set; }
}
Drag options to blanks, or click blank then click option'
Aprice
BgetPrice
CPrice
DPriceValue
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase property names.
Using method-like names instead of property names.
4fill in blank
hard

Fill both blanks to declare an auto-implemented property named IsAvailable of type bool.

C Sharp (C#)
public class Item {
    public [1] [2] { get; set; }
}
Drag options to blanks, or click blank then click option'
Abool
BIsAvailable
CAvailable
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean instead of bool.
Using incorrect property names like Available.
5fill in blank
hard

Fill all three blanks to declare an auto-implemented property named Title of type string with public get and private set accessors.

C Sharp (C#)
public class Book {
    public [1] [2] { get; [3] set; }
}
Drag options to blanks, or click blank then click option'
Astring
BTitle
Cprivate
Dpublic
Attempts:
3 left
💡 Hint
Common Mistakes
Making the setter public when it should be private.
Using incorrect property names or types.