Home »
MCQs »
C# MCQs
What is the correct syntax for foreach statement in C#?
43. What is the correct syntax for foreach statement in C#?
-
foreach(type variable_name in collection_name); {
statement(s);
}
-
foreach(type variable_name in collection_name) {
statement(s);
}
-
foreach(variable_name As Type in collection_name){
statement(s);
}
-
foreach(dim type variable_name in collection_name) {
statement(s);
}
Answer: B)
foreach(type variable_name in collection_name) {
statement(s);
}
Explanation:
The correct syntax of foreach statement is:
foreach(type variable_name in collection_name) {
statement(s);
}