Friday, March 24, 2017

String Interpolation and Exception filters in C# 6


C# 6 gives us a new way to compose strings. We used to have string.Format functionality to accomplish this just like in this example.
Now we can get the same result by using new feature.
You can call other functions to help your member.
You can even use conditional operators or linq if you like to.
You can use it when you are overriding functions.
Exception Filters
When error occurs, Exception Filters helps to determine if the Catch clause should be applied to the thrown error. I am going to give an example from Microsoft website for this one.

When error occurs, our code goes in the catch part only if message contains 301 or 304

No comments:

Post a Comment