CSharp examples for Custom Type:Exception
Exception Filter by exception message
using System;// w w w.ja v a2 s. c o m using System.ComponentModel; class FirstExceptionFilter { static void Main() { string[] messages = { "You can catch this", "You can catch this too", "This won't be caught" }; foreach (string message in messages) { try { throw new Exception(message); } catch (Exception e) when (e.Message.Contains("catch")) { Console.WriteLine($"Caught '{e.Message}'"); } } } }