Complete the code to safely access the Length property of the string variable.
int? length = name[1]Length;The null-conditional operator ?. safely accesses members only if the object is not null.
Complete the code to safely call the ToUpper method on the string variable.
string? upperName = name[1]ToUpper();The null-conditional operator ?. calls the method only if the object is not null, avoiding exceptions.
Fix the error in the code to safely get the length of the string or return 0 if null.
int length = name[1]Length ?? 0;
The null-conditional operator ?. returns null if name is null, so the null-coalescing operator ?? can provide a default value.
Fill both blanks to safely access the first character of the string or return '?' if null or empty.
char firstChar = name[1]Length > 0 ? name[2][0] : '?';
Use ?. to safely check Length, then use . to index because the condition ensures name is not null or empty.
Fill all three blanks to safely get the length of the first string in the array or return 0 if null.
int length = names[1]Length > 0 ? names[0][2]Length [3] 0 : 0;
Use ?. to check if names is not null before accessing Length, ?. to safely access the Length of the first element, ?? to provide default 0 if the first string is null. The ternary returns 0 if array is null or empty.