int a = 10; int b = 20; if (a.GetType() == b.GetType()) { Console.WriteLine("The item types of a and b are the same."); } else { Console.WriteLine("The item types of a and b are different."); }
using System.Collections; ArrayList list1 = new ArrayList(); ArrayList list2 = new ArrayList(); if (list1.GetType() == list2.GetType()) { Console.WriteLine("The item types of list1 and list2 are the same."); } else { Console.WriteLine("The item types of list1 and list2 are different."); }This example compares the item types of two ArrayList objects, list1 and list2. Since they are both of type ArrayList, the output will be "The item types of list1 and list2 are the same." The ItemType Equals method is part of the System.Type class in the .NET Framework library.