Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 1, 2011, 1:35 AM EDT
Manikavelu VelayuthamRank #413 · 6K reputationPosted Apr 1, 2011, 4:15 AM EDT
Because my friend tried the same answer when he got interviewed. But Interviewer argued there is some other way like that.
I too searched in google, but didnt get a valid point.
VulpesRank #55 · 29.2K reputationPosted Apr 1, 2011, 4:40 AM EDT
As far as the 'catch' clause is concerned you don't need to display a message to the user but can simply handle the exception 'silently'.
Suthish NairRank #92 · 22.8K reputationPosted Apr 1, 2011, 11:09 AM EDT
Suppress means how to avoid system generated errors and show user defined error messages.
For example, this not accurate but will give you an idea:
static void Main(string[] args) {
try
{
int x = 1;
int y = 0;
int z = x / y;
}
catch (Exception)
{
CatchErrors err = new CatchErrors();
//Console.WriteLine(err.Message);
Console.WriteLine(err.ShowErrors());
Console.ReadLine();
}
}
public class CatchErrors : Exception
{
public CatchErrors() { }
public void GetErrors()
{
throw new Exception();
}
public string ShowErrors()
{
return "Hello, You can't catch me out with that one!";
}
}
VulpesRank #55 · 29.2K reputationPosted Apr 1, 2011, 1:02 PM EDT
If they'd asked me that question at an interview and told me my answer was wrong, that's exactly what I'd have told them!
Suthish NairRank #92 · 22.8K reputationPosted Apr 1, 2011, 1:33 PM EDT
Same thing happens to me once :).
I asked what you mean by suppress the exception.
I was not able to answer what he wants.
But after the session i asked him about this.
He said, how to show user defined messages when exception occurs.
I got confused whats the relation that.
Anyway, Still am not sure that was the answer for that. But taut of sharing it here.
Suppress also means forcibly put an end to.
VulpesRank #55 · 29.2K reputationPosted Apr 1, 2011, 1:43 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Apr 2, 2011, 8:08 AM EDT