Implementing Java's "Exceptions Thrown by a Method" in C#
I have been working on a conversion project for last few days where I need to convert a Java library to C#. At one point I came to java's certain feature called Exceptions Thrown by a Method. Here is a little glimpse of it:
public boolean isRequest() throws NullPointerException
// blocks of code implementing isRequest() method;
For the C# implementation of this code snippet, I searched the web and quite shockingly found that, C# does not support throwing exceptions in the compile time.
Now my question is, how can I implement this code portion in a C# library?
Congratulations! You're no longer a DaniWeb newbie.<br /> <br />
Your DaniWeb account has just been upgraded from newbie status and now you have the ability to take advantage of everything the community has to offer.<br /> <br />
You can now enjoy an advertisement-free DaniWeb by ticking the checkbox to Disable Ads in your profile. You will no longer have to fill out the human verification check when you post. You can also now send unlimited private messages, contribute new code snippets, and tag articles with never-before-used tags.
@tinstaafl, its not about just throwing exception. In Java using this block(Exceptions Thrown by a Method, follow my link if u please) of code u can check for an exception on compilation time. In C# one cannot simply use a try block which will be executed in compile time, that's why I'm saying C# does not provide this feature by default. I need to know how I can implement it manually.
Thanks for your comment.
Edited 3 Years Ago by mesbahuk: needed to amplify some words
As a programmer, you really should be aware of what code can throw an exception already. Most documentation will tell you and (especially in possible NullReference cases) you should be checking for null before hand.
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"