For example, I have a class called Clothing that inherits from a abstract class of Product.
public class Clothing : Product
{
public bool IsInSeason {get; set;}
public string Material {get; set; }
public Decimal IsFeatured { get; set; }
}
Edit: In a function, how would I be able to pass the string "Clothing" and have a typeof the class returned?
ReturnTypeOfClassBasedOffOfString(string class)
{
// ...
}
Use Type.GetType(string)
Note that sometime the class name won't be enough. Sometime you will need to provide the AssemblyQualifiedName
"If the type is in the currently executing assembly or in Mscorlib.dll, it is sufficient to supply the type name qualified by its namespace."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With