C# Program to Check a Class is a Sub-Class of a Specified Class or Not Last Updated : 23 Nov, 2021 Comments Improve Suggest changes Like Article Like Report A class is a collection of methods, variables, and objects. A subclass is a class that is extended from the parent class. It should achieve all the properties from the parent class. Its syntax is similar to a class. Using: operator we can create the subclass. We can check the class is a subclass of the specific class or not by using the IsSubclassOf() method of the Type class. Or we can say that IsSubclassOf() method is used to check whether the current Type is derived from the given type. It will return true if the subclass is specific to the parent class. Otherwise, it will return false. This method will throw ArgumentNullException when the class name is null type. This method is used to: Check whether the class is derived from another class.Check whether a type is derived from the ValueType.Check whether the type is derived from Enum.Check whether a type is derived from the delegate.Syntax: public virtual bool IsSubclassOf(Type c);Example 1: C# // C# program to check whether a class is // a sub-class of a specified class or not using System; // Create a class named Geeks public class Geeks{} // Create a subclass that is from Geeks class public class smallGFG : Geeks{} // Create a class named mygg public class mygg{} class GFG{ // Drived code public static void Main() { // Check the class is a subclass of the class // Using IsSubclassOf() method Console.WriteLine(typeof(smallGFG).IsSubclassOf(typeof(Geeks))); Console.WriteLine(typeof(Geeks).IsSubclassOf(typeof(smallGFG))); Console.WriteLine(typeof(mygg).IsSubclassOf(typeof(Geeks))); } } Output: True False FalseExample 2: C# // C# program to check whether a class is // a sub-class of a specified class or not using System; // Create a class named Geeks public class Mypet { public void color() { Console.WriteLine("I like pink color hair"); } } // Create a subclass that is from Mypet class public class Dog : Mypet{} class GFG{ // Driver code public static void Main() { // Check the class is a subclass of the class // Using IsSubclassOf() method if (typeof(Dog).IsSubclassOf(typeof(Mypet)) == true) { Console.WriteLine("Given class is a sub class"); } else { Console.WriteLine("Given class is not a sub class"); } } } Output: Given class is a sub class Comment More infoAdvertise with us Next Article C# Program to Check a Specified Type is an Array or Not 171fa07058 Follow Improve Article Tags : C# C# Programs Similar Reads C# Program to Check a Specified Class is an Abstract Class or Not Abstraction is the process to hide the internal details and showing only the functionality. The abstract keyword is used before the class or method to declare the class or method as abstract. In this article, we will learn how to check a specified class is an abstract class or not. To do this task w 2 min read C# Program to Check a Specified Class is a Sealed Class or not A Sealed class is a class that will not let the users inherit the class. We can create a sealed class using sealed keywords. This keyword tells the compiler that the class is a sealed class. In this article, we will learn how to check the specified class is a sealed class or not. So we use the IsSea 2 min read C# Program to Check a Specified Type is a Class or Not A class is a collection of methods, variables, and objects. Or we can say that a class is a blueprint using which an object is created. So to check whether the specified type is a class as well as delegates or not we use the IsClass property of the Type class. It will return true if the type is clas 2 min read C# Program to Check a Specified class is a Serializable class or not Serialization is a method of converting an object into a stream of bytes that will be used to store the object in the database, or memory, or file, etc so that we can easily read back and convert it back to an object. So to check whether a specified class is serializable or not we use the IsSerializ 2 min read C# Program to Check a Specified Type is an Array or Not In C#, an array is a group of homogeneous elements that are referred to by a common name. So in this article, we will discuss how to check the variable is of array type or not. To do this task, we use the IsArray property of the Type class. This property is used to determine whether the specified ty 2 min read C# Program to Check a Specified Type is a Pointer or not A pointer is a variable that contains the references of another variable. Or in other words, the pointer is a variable that stores the address of the same type of variable. For example, a string pointer can store the address of a string. In C#, we can able to check the given type is a pointer or not 2 min read Like