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

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

iis - ASP.Net Core CreatedAtAction in HttpPost action returns 201 but entire request ends with 500 -