c# - using typeof() to search for all object -


public class classa {    int num = 10; }  classa = new classa(); classa b = new classa(); classa c = new classa(); a.gettype(); //we can result "classa" 

here question. anyway can object of classa using typeof(classa)? or other way? kind help

if want

get object of classa

you may want organize classa instances collection, say, array , use linq:

object[] source = new object[] {   "string",   new classa(), //    new object(),   new classa(), // , should filtered out   null };  ...  classa[] result = source   .oftype<classa>()   .where(item => item != null) // may want filter   .toarray(); 

Comments

Popular posts from this blog

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -

maven - jacoco coverage per test setup -