1. Back To Blog

C# interview questions: - What is exception bubbling in C#?

Many times when you catch exception, do not want them to be handled during that time. Rather you would like to propagate the same to the caller and let the caller handle the same. For such kind of scenarios we use exception bubbling.


For instance if you have raised exception in a business class, you would probably like to bubble it to the UI so that it can be displayed in a message box for the end user.


Below is a sample code where "Method1" raises the error to the calling code and the calling handles the same by displaying the same using "Console.Write" function. In order to bubble the error up we need to say "throw" or "throw ex". The code is also circled below.


 

C# interview questions video: - What is the difference between Constant and Read only?



See for more stuffs on important c# interview questions


Regards,


Click to view more from author's on C# training

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social