csharp1try2{3 // Code that might throw an exception4 int result = int.Parse("not a number");5}6catch (FormatException ex)7{8 // Handle the exception9 Console.WriteLine($"Error: {ex.Message}");10}
1try2{3 // Code that might throw an exception4 int result = int.Parse("not a number");5}6catch (FormatException ex)7{8 // Handle the exception9 Console.WriteLine($"Error: {ex.Message}");10}