"c# check if object is instance of class" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "c# check if object is instance of class" answered properly. Developers are finding an appropriate answer about c# check if object is instance of class related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like c# check if object is instance of class. Enter your desired code related query in the search bar and get every piece of information about C# code related question on c# check if object is instance of class.
c# check if object is instance of class
using System;
public interface IExample {}
public class BaseClass : IExample {}
public class DerivedClass : BaseClass {}
public class Example
{
public static void Main()
{
var interfaceType = typeof(IExample);
var base1 = new BaseClass();
var base1Type = base1.GetType();
var derived1 = new DerivedClass();
var derived1Type = derived1.GetType();
int[] arr = new int[11];
Console.WriteLine("Is int[] an instance of the Array class? {0}.",
typeof(Array).IsInstanceOfType(arr));
Console.WriteLine("Is base1 an instance of BaseClass? {0}.",
base1Type.IsInstanceOfType(base1));
Console.WriteLine("Is derived1 an instance of BaseClass? {0}.",
base1Type.IsInstanceOfType(derived1));
Console.WriteLine("Is base1 an instance of IExample? {0}.",
interfaceType.IsInstanceOfType(base1));
Console.WriteLine("Is derived1 an instance of IExample? {0}.",
interfaceType.IsInstanceOfType(derived1));
}
}
// The example displays the following output:
// Is int[] an instance of the Array class? True.
// Is base1 an instance of BaseClass? True.
// Is derived1 an instance of BaseClass? True.
// Is base1 an instance of IExample? True.
// Is derived1 an instance of IExample? True.
All those coders who are working on the C# based application and are stuck on c# check if object is instance of class can get a collection of related answers to their query. Programmers need to enter their query on c# check if object is instance of class related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c# check if object is instance of class for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of c# check if object is instance of class while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "c# check if object is instance of class". Visit this developer's friendly online web community, CodeProZone, and get your queries like c# check if object is instance of class resolved professionally and stay updated to the latest C# updates.