What does this code output?
1: namespace GenericsExample
2: {
3: using System;
4: using System.Collections.Generic;
5: using System.Text;
6:
7: class Implementor : IGenericInterface<int, string>,
INonGenericInterface { }
8:
9: interface IGenericInterface { }
10:
11: interface INonGenericInterface { }
12:
13: class Program
14: {
15: static void Main (string[] args)
16: {
17: Type[] interfaces = typeof(Implementor).GetInterfaces();
18:
19: if (interfaces != null)
20: {
21: foreach (Type iface in interfaces)
22: {
23: Console.WriteLine("Interface type '{0}'", iface.Name);
24:
25: if (iface.IsGenericType)
26: {
27: Type[] genericParams = iface.GetGenericArguments();
28:
29: foreach (Type genParam in genericParams)
30: {
31: Console.WriteLine("Generic parameter type '{0}'",
genParam.Name);
32:
33: if (genParam == typeof(Int32))
34: {
35: Console.WriteLine("\tFound an interger!");
36: }
37: }
38: }
39: }
40: }
41:
42: Console.WriteLine();
43: Console.WriteLine("Press to exit.");
44: Console.ReadLine();
45: }
46: }
47: }
I will post an "nice to know" tomorrow…