Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TypeOf
- {
- class Program
- {
- static void Main(string[] args)
- {
- IA a = new A1();
- IA b = new A2();
- IA c = new A3();
- var d = new A4();
- var list = new ArrayList();
- list.Add(a);
- list.Add(b);
- list.Add(c);
- list.Add(d);
- foreach (var item in list)
- {
- Console.Write(item.GetType());
- if (item is IA)
- {
- Console.Write(" is IA");
- }
- if (item is BaseA)
- {
- Console.Write(" is BaseA");
- }
- Console.Write(" Based from" + item.GetType().BaseType);
- foreach (var ifType in item.GetType().GetInterfaces())
- {
- Console.Write(" Implemented " + ifType);
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- public class A1: BaseA,IA { }
- public class A2: IA, IB { }
- public class A3: BaseA,IA { }
- public class A4: BaseA { }
- interface IA
- {
- }
- interface IB
- {
- }
- public abstract class BaseA
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement