1

I am currently moving from Java to C#. While connecting the dots on comparison between the two I came across Exceptions.

As in Java, you must either handle an exception or mark the method as one that may throw it using the throws keyword. I have not been able to find any such way of marking methods in C#.

void show() throws Exception { throw new Exception("my.own.Exception"); } 

So the question is simple how can I achieve such java like exception throwing in C#, that is what would be equivalent to the above code in C#.

2
  • 3
    There's no throws clause in C#, so no, you can't do the same thing in C#. Commented Nov 16, 2019 at 8:15
  • 1
    You can use try, catch method for handling the exceptions in c#. You will get many useful documents regarding the same Commented Nov 16, 2019 at 8:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.