Save
SEMESTER 01
PLATFORM DEV THEORY
PD1: Chapter 5: Iterations
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Soeroe
Visit profile
Cards (35)
What is the generic List datatype in C#?
A generic collection datatype that contains a dynamic number of
elements
View source
What is required to complete the generic List datatype?
An extra datatype known as the Type
parameter
View source
What are examples of List datatypes in C#?
List<
int
>, List<
string
>, List<
float
>
View source
How does the datatype inside a List affect its elements?
It
specifies
which
datatype
the
elements
in the
list
adhere
to
View source
What notation is used to retrieve an item at a specific position in a List?
Square brackets
notation []
View source
What is the term for the squared bracket notation used in Lists?
Indexer
View source
What method can be used to remove all elements from a List?
The
Clear
method
View source
How does the capacity of a List change when elements are added?
It grows
dynamically
as needed
View source
What is the purpose of iteration statements in C#?
To execute commands
multiple
times
View source
What must be written between parentheses in a while statement?
The
test condition
View source
What happens if the test in a while statement fails immediately?
The
code block
is not executed
View source
What is a potential risk of a while loop if the test is always true?
It can lead to an
infinite loop
View source
When is a while loop particularly useful?
When the number of
iterations
is not
known
in advance
View source
What does the second while loop in the practical example do?
Generates
random
numbers
until
the
secret
number
is found
View source
What happens if the user provides a number outside the range [0-20]?
The
program
will never find a solution
View source
How does a do statement differ from a while statement?
The
test
comes after the code block in a do statement
View source
What is a benefit of using a do statement?
The code block is
executed
at least once
View source
What is the structure of a for statement in C#?
It contains a for keyword with three
control elements
View source
What are the three control elements in a for statement?
Initializer
,
test condition
, and
increment
View source
What is the significance of the control variable in a for loop?
It is used to process elements
related to the
loop
View source
What does it mean that positions in a list are 0 based?
The first
index
is 0, meaning indices range from 0 to
count
-1
View source
What is the purpose of the foreach instruction?
To process each element in a collection automatically
View source
What does the break keyword do in a loop?
It
moves
control
to
the
first
instruction
after
the
loop
View source
What is the function of the continue keyword in a loop?
It halts the current iteration and starts the next one
View source
What is the yield keyword used for?
To simulate collection behavior without providing the collection
View source
Why is it not allowed to delete an item from a List using a foreach statement?
It causes a runtime error
View source
What happens if you try to delete items from a List while iterating through it?
Only half the elements may be removed
View source
What is the recommended method to delete all items in a List?
Use the
Clear method
View source
What is the relationship between while and for statements?
Each can perform the same logic
View source
What must be included in a for loop to avoid an infinite loop?
A break or return statement
View source
What are the key features of the List datatype in C#?
Generic collection
datatype
Dynamic number of elements
Requires a
Type parameter
Supports
indexers
for element retrieval
Allows various operations using dot-notation
Supports
Clear method
to remove all elements
Dynamic
capacity
that grows as needed
View source
What are the types of iteration statements in C#?
while statement
do statement
for statement
foreach statement
View source
What are the differences between while, do, and for statements?
while: test
condition
before executing
code block
do: test condition after executing code block
for: includes initialization, test condition, and
increment
in one line
View source
What are the uses of break, continue, and yield keywords in loops?
break: exits the loop
continue: skips to the next iteration
yield: simulates collection behavior without a complete collection
View source
What are the methods for deleting elements in a List?
Use
Clear
method to remove all elements
Avoid deleting while iterating with
foreach
Use a
for loop
to remove specific elements
View source