Exceptions in C#

  • Thread starter Thread starter Ohad Young
  • Start date Start date
O

Ohad Young

Hi,

In Java each method contains an optional throws statement with a list of
exceptions
thrown by the method.

Is there something similar that can be done in C#?

Ohad
--
Ohad Young
Medical Informatics Research Center
Ben Gurion University
Information System Eng
Office Phone: 972-8-6477160
Cellular Phone: 972-54-518301
E-Mail: (e-mail address removed)
 
Hi,

Yes in C# as well you can throw exceptions ...

public TestMethod( int i, int j)
{
try
{
...
...
// Called function may throw exception.
ExceptionMethod();
//Creates an instance of System.Exception and throws.
if( k == 0)
throw new Exception();
}
catch (Exception e)
{
}
Console.Writeline("Code after exception");
}


Nirosh.
 
Ohad Young said:
In Java each method contains an optional throws statement with a list of
exceptions thrown by the method.

Is there something similar that can be done in C#?

No, C# (and .NET in general) doesn't have checked exceptions.
 
Back
Top