Its been quite some time that I read about Exception filters in C# 6.0
I was to trying to use it in action. But not sure why I am getting the below error.
CS1003 Syntax error, 'when' expected C_6.0
This is how my snippet looks like
using System;
using static System.Console;
namespace C_6._0
{
public class Program
{
static void Main(string[] args)
{
int val = 1;
try
{
WriteLine("Enter value :");
val = int.Parse(ReadLine());
}
catch (Exception ex) if (val == 0)
{
WriteLine("Input Invalid");
}
catch (Exception ex)
{
WriteLine(ex.Message);
}
ReadLine();
}
}}
I checked the version of C#, its 6.0 in my visual studio by
Properties -> Build -> Advanced Build Settings
Thanks.
if (val == 0)towhen (val == 0)?ifbut they eventually changed it towhen.