_____________________________________________
Exception Handling of C#.
_____________________________________________
// Throw an exception
Exception up = new Exception("Something is really wrong.");
throw up; // ha ha
// Catch an exception
try {
y = 0;
x = 10 / y;
}
catch (Exception ex) { // Argument is optional, no "When" keyword
Console.WriteLine(ex.Message);
}
finally {
// Requires reference to the Microsoft.VisualBasic.dll
// assembly (pre .NET Framework v2.0)
Microsoft.VisualBasic.Interaction.Beep();
}
____________________________________________________________________
____________________________________________________________________
No comments:
Post a Comment