Exceptions in C#

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)
 
C

Champika Nirosh

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.
 
J

Jon Skeet [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top