Type.IsAssignableFrom(Type) Method is used determine whether an instance of a specified type can be assigned to a variable of the current type.
Syntax: public virtual bool IsAssignableFrom (Type c);
Here, it takes the type to compare with the current type.
Return Value: This method returns true if any of the following conditions is true:
- c and the current instance represent the same type.
- c is derived either directly or indirectly from the current instance. c is derived directly from the current instance if it inherits from the current instance; c is derived indirectly from the current instance if it inherits from a succession of one or more classes that inherit from the current instance.
- The current instance is an interface that c implements.
- c is a generic type parameter, and the current instance represents one of the constraints of c.
Below programs illustrate the use of Type.IsAssignableFrom() Method:
Instance of a specified type can be assigned to a variable of the current type.
Instance of a specified type can't be assigned to a variable of the current type.
- Difference between Method Overriding and Method Hiding in C#
- C# | Math.Exp() Method
- Decimal.Add() Method in C#
- C# | Math.Pow() Method
- C# | Clone() Method
- TimeSpan.Add() Method in C#
- C# | PadRight() Method
- C# | EndsWith() Method
- C# | Remove() Method
- C# | Join Method | Set - 2
- DateTimeOffset.Add() Method in C#
- Anonymous Method in C#
- C# | Uri.IsHexEncoding() Method
- C# | Replace() Method
- C# | Insert() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.