c# - detecting type of generics within generics -
i have method accepts many different types of objects storage:
public void store<t>(t item) { // works fine if (item foo) { // ... } // works fine else if (item observation<imagesignal>) { // ... } // isn't detected else if (item observation<signal<ispectrum>>) { // ... } else { // observation<signal<ispectrum>> hits this. throw new notsupportedexception(); } } can tell me how can detect this?
edit: passing in object wraps object. eric right. problem solved. quick responses, however.
in case wouldn't better overload store function? easier follow logic.
public void store(foo item) { } public void store(observation<imagesignal> item) { } public void store(observation<signal<ispectrum>> item) { }
Comments
Post a Comment