c# - How can I throw exception inside a Generic Type Method? -


is there way throw or safely return exception inside generic method?

my sample code looks this:

public ienumerable<t> findaverage<t>(float a, float b) t : new () {     try     {        ..... averaging instructions here......     }     catch(exception e)     {        throw e        } } 

now seems problem whenever create test classes, mean literally separate projects test, error redirects main source code of created library. thought there way return exceptions without being redirected main library source?

any || ideas || simple answers great. thanks!

generally speaking, unless there clear need so, better not catch/re-throw exceptions @ low level of code, instead let them bubble front end (i.e. either front end or test code) them handle them appropriate.

in case, if exception in averaging code, reasonable handling of be? if not handling this, don't catch @ all.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -