Complete the code to declare an implicitly typed variable holding the number 10.
var number = [1];The var keyword lets the compiler infer the type from the assigned value. Here, 10 is an integer, so number becomes an int.
Complete the code to declare an implicitly typed variable holding the text "hello".
var greeting = [1];The var keyword infers the type from the assigned value. Text must be in double quotes to be a string in C#.
Fix the error in the code by completing the declaration of an implicitly typed variable holding a decimal number.
var price = [1]m;Decimal literals in C# require the suffix m. The number must be written with a dot, not a comma, and without quotes.
Complete the code to declare an implicitly typed variable holding a list of integers and initialize it with values 1, 2, and 3.
var numbers = new [1]<int> {1, 2, 3};
To create a list of integers, use List<int> and initialize it with curly braces { } containing the values.
Complete the code to declare an implicitly typed variable holding a dictionary with string keys and int values, initialized with two entries.
var ages = new Dictionary<[1], [2]> { {"Alice", 30}, {"Bob", 25} };
The dictionary keys are strings and values are integers. Use curly braces { } to initialize the dictionary with key-value pairs.