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

Why C# and the .NET ecosystem - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable of type string in C#.

C Sharp (C#)
string name = [1];
Drag options to blanks, or click blank then click option'
Aint
BJohn
C"John"
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the quotes around the string value.
2fill in blank
medium

Complete the code to create a simple method that returns an integer in C#.

C Sharp (C#)
public int GetNumber() {
    return [1];
}
Drag options to blanks, or click blank then click option'
A5
B"5"
Cfive
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a string instead of an integer.
3fill in blank
hard

Fix the error in the code to correctly instantiate a List of strings in C#.

C Sharp (C#)
List<string> names = new [1]();
Drag options to blanks, or click blank then click option'
ASet
BDictionary
CArray
DList<string>
Attempts:
3 left
💡 Hint
Common Mistakes
Using Array or Dictionary instead of List.
4fill in blank
hard

Fill both blanks to create a dictionary with string keys and int values in C#.

C Sharp (C#)
Dictionary<[1], [2]> ages = new Dictionary<[1], [2]>();
Drag options to blanks, or click blank then click option'
Astring
Bint
Cfloat
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using float or bool instead of int for values.
5fill in blank
hard

Fill all three blanks to create a simple class with a property and a method in C#.

C Sharp (C#)
public class Person {
    public [1] Name { get; set; }
    public [2] Age { get; set; }
    public void [3]() {
        Console.WriteLine($"Name: {Name}, Age: {Age}");
    }
}
Drag options to blanks, or click blank then click option'
Astring
Bint
CDisplay
DShow
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong types or method names that are not verbs.