c# - Inheritance related question -


i have class base. , b extend base. there class relationship contains 2 base objects (source, target). possible determine whether source/target or b instance?

thanks.

christian

ps:

here little add on. using automapper , map type of source/target string called 'type' - gettype did not work (actually works -s ee comments - , solutions too):

mapper.createmap<item, itemviewmodel>()                 .formember(dest => dest.name, opt => opt.mapfrom(src => src.itemname == null ? "" : src.itemname.name))                 .formember(dest => dest.type, opt => opt.mapfrom(src => src.gettype().tostring())); 

how can use is/as in scenario?

yup:

if (source a)  if (source b) 

etc

or:

a sourcea = source a; if (sourcea != null) {    ... } 

etc

see this question more guidance - , there plenty of other similar ones, too.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -