Save
SEMESTER 01
PLATFORM DEV THEORY
Samenvatting van leerkracht
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Soeroe
Visit profile
Cards (29)
What are properties in C#?
Members of
classes
, structures, and
interfaces
View source
What are member variables in C#?
Fields of
classes
,
structures
, and
interfaces
View source
How do properties extend fields in C#?
They expose
public
access while hiding
logic
View source
How are properties accessed in C#?
Using the same syntax as
fields
View source
What does the 'get' accessor do in a property?
Returns the value of a
private field
View source
What does the 'set' accessor do in a property?
Assigns a value to a
private field
View source
What is the purpose of the 'Main' method in C#?
Entry point for the
application
View source
How can properties be implemented as expression-bodied members?
Using the
=>
symbol followed by an expression
View source
When should constructor parameters be used in C#?
For required
properties
during object construction
View source
How would you define an auto property with a private setter?
public string
Name {
get
; private set; }
View source
What are property initializers used for?
For additional configuration after
construction
View source
How would you create a person object with optional address?
Person
personObject = new Person("John Doe",
24
) {
Address
= "42 Adams Street" };
View source
What does the 'const' keyword do in C#?
Makes
a
field
constant
and
unmodifiable
View source
When must constants be initialized?
At the time of
declaration
View source
What is a compile-time constant?
A
const field
initialized at
declaration
View source
What does the 'readonly' keyword allow in C#?
Field initialization
at
declaration
or
constructor
View source
How can a readonly field be modified?
Only in the
constructor
of the class
View source
What does the 'static' keyword indicate?
Members shared by all
class
objects
View source
What can static members access?
Only static members of the
same class
View source
What happens if a class is declared static?
All
members
of the class must be static
View source
When should you use 'const' in C#?
For simple
values
that don't change
View source
When should you use 'readonly' in C#?
For
variables
that shouldn't
change
after
initialization
View source
What does the 'typeof()' function do?
Gets the type at
compile time
View source
What does the 'GetType()' function do?
Gets the runtime type of an
instance
View source
What does the 'is' operator do?
Checks if an instance is in the
inheritance
tree
View source
How do you cast an object to a specific type?
Using (Type) object
syntax
View source
How do you implement polymorphism in C#?
By assigning a
derived class
to a
base class
reference
View source
What does the 'as' operator do in C#?
Attempts to cast an object to a type
View source
How can inline casting be done in C# 7+?
Using the
'is'
operator with assignment
View source