Complete the code to declare a variable that stores an integer value.
int number = [1];The variable number is declared as an integer and assigned the value 10. Using quotes would make it a string, which is incorrect here.
Complete the code to allocate memory for a new object of class Person.
Person p = [1] Person();In C#, the new keyword is used to allocate memory and create a new object instance.
Fix the error in the code to correctly release unmanaged resources by implementing the Dispose pattern.
public void Dispose() [1]The Dispose method should call Dispose(true) and then GC.SuppressFinalize(this) to release managed and unmanaged resources properly and prevent finalization.
Fill both blanks to create a dictionary that maps strings to their lengths, but only include words longer than 3 characters.
var lengths = new Dictionary<string, int> { { [1], [2] } };The dictionary entry maps the string "word" to its length 4. "word" has 4 characters, which is longer than 3.
Fill both blanks to create a method that returns the size of an array safely, returning 0 if the array is null.
public int GetSize(int[] arr) { return arr [1] [2] 0; }The expression arr?.Length ?? 0 returns the length of the array if it is not null; otherwise, it returns 0.