if ConvertAll throw an exception on one element, can i just skip this element and continue to the next element?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. The exception will need to be handled somewhere. If you expect exceptions to happen in the converter (and this is OK for the application), you must have a try-catch within the converter (the following code sample will return
nullfor failed conversions):(yes, I know I should have used
int.TryParse, but that would not throw an exception…)However, eating exceptions like that always gives the smell of a workaround, and is nothing I would like to have in my code.