dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » .NET » C#
Language: .NET
Expertise: Intermediate
Jul 16, 2018

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Conditional Catch Blocks in C#

We can now have conditional catch blocks in C#. The catch block will execute only if the condition evaluates to true.

Please see below for an example.

catch (Exception ex)
{
  if (ex.Message.Contains("TLS"))
  {
      //capture TLS exception.
  }
  else
  {
     //do what you want or just throw
     throw
  }
}
Srinath M S
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date