WorksheetsC# Structured, Selection and Iteration
Total questions: 15
Worksheet time: 8mins
What is a correct syntax to output "Hello World" in C#?
Console.Writeline("Hello World");
Console.WriteLine("Hello World");
Console.WriteLine("Hello World ");
Console.WriteLine("Hello World");
How do you insert COMMENTS in C# code?
/* This is a comment
# This is a comment
// This is a comment
Which data type is used to create a variable that should store text?
String
int
txt
string
How do you create a variable with the numeric value 5?
num x = 5
int x = 5;
int x == 5;
double x = 5;
How do you create a variable with the decimal number 2.8?
byte x = 2.8;
double x = 2.8;
int x = 2.8;
int x = 2.8D;
Which string handling function can be used to find the length of a string?
.Length()
.length();
.getLength();
.Length
Which operator is used to add together two values?
The & sign
The + sign
The * sign
The value of a char variable can be surrounded by single quotes
True
False
When casting you assign a value of one data type to another type
True
False
Which operator can be used to compare two values?
==
=
<>
><
How do you call a method in C#?
MyMethod;
MyMethod();
MyMethod[];
(MyMethod);
How do you start writing an if statement in C#?
if (x>y)
if x> y:
if x > y then:
How do you start writing a while loop in C#?
while x> y {
while x > y:
x > y while {
while (x > y) {
Which keyword is used to return a value inside a method?
void
break
return
get
Which statement is used to stop a loop?
exit
stop
return
break
