Why does try-catch speed up my C# code execution?
Hi everyone. I'm a beginner C# developer and I've encountered very strange behavior. I have a method that processes an array of numbers. I decided to check performance using Stopwatch and found that the version with try-catch runs faster than the one without it! Here's the simplified code:
```csharp
// Slow version (without try-catch)
public static void ProcessWithoutTryCatch(int[] data)
{
for (int i = 0; i < data.Length; i++)
{
if (data[i] > 0 && data[i] < 100)
{
// Some simple logic
int result = data[i] * 2;
}
}
}
// Fast version (with try-catch)
public static void ProcessWithTryCatch(int[] data)
{
for (int i = 0; i < data.Length; i++)
{
try
{
if (data[i] > 0 && data[i] <