Complete the code to convert an integer to a double.
int number = 10; double result = (double)[1]; Console.WriteLine(result);
We cast the integer variable number to a double using (double)number.
Complete the code to convert a string to an integer using a built-in method.
string text = "123"; int number = [1](text); Console.WriteLine(number);
ToString which converts to string, not integer.Convert.ToDouble which converts to double, not int.The int.Parse() method converts a string to an integer.
Fix the error in the code to safely convert a string to an integer using TryParse.
string input = "456"; if (int.[1](input, out int result)) { Console.WriteLine(result); } else { Console.WriteLine("Conversion failed"); }
Parse which throws exceptions on failure.Convert which does not have TryParse.int.TryParse() attempts to convert a string to int safely without throwing exceptions.
Fill both blanks to convert a double to an integer using casting and print the result.
double value = 9.78; int intValue = ([1]) value; Console.WriteLine([2]);
double instead of int.We cast the double value to int and print the integer variable intValue.
Fill all three blanks to create a dictionary with string keys and integer values, filtering only values greater than 10.
var data = new Dictionary<string, int> { {"a", 5}, {"b", 15}, {"c", 25} };
var filtered = data.Where(kv => kv.Value [1] 10)
.ToDictionary(kv => kv.[2], kv => kv.[3]);
foreach (var item in filtered)
{
Console.WriteLine($"{item.Key}: {item.Value}");
}Key and Value in the dictionary creation.The code filters dictionary entries where the value is greater than 10, then creates a new dictionary using the original keys and values.