Problem while creating type from string RRS feed

  • Question

  • For my persistence library I would like to create type dynamically.
    Unfortunately I have a problem with generic type. The code below fails at runtime, I'm not sure why..

    var tDict = Type.GetType("System.Collections.Generic.Dictionary`2[]");
    var tDict2 = tDict.MakeGenericType(typeof(int), typeof(string));

    Any insight would be appreciated! :)

    Monday, November 25, 2013 2:37 PM


  • Ok, found it! This will do:

    var tDict = Type.GetType("System.Collections.Generic.Dictionary`2");

    • Marked as answer by Lloyd Monday, November 25, 2013 3:06 PM
    Monday, November 25, 2013 3:06 PM