Button btn = new Button(); Type buttonType = btn.GetType(); Console.WriteLine("Control type is: " + buttonType.FullName);
foreach (Control ctrl in ControlCollection) { Type ctrlType = ctrl.GetType(); if (ctrlType == typeof(DropDownList)) { DropDownList ddl = (DropDownList)ctrl; // do something with dropdownlist } }This code iterates through a collection of controls and checks their type dynamically using the `GetType` method. If the control is a DropDownList, it is cast to that type and some action is taken. The `GetType` method is part of the System.Web assembly.