NET - Explain how to create and consume a Generic type.

Explain with an example how to create and consume a Generic type.

public static object CreateMethod(Type generic, Type innerType, params object[] args)
{
      System.Type type = generic.MakeGenericType(new System.Type[] { innerType });
      return Activator.CreateInstance(type, args);
}

To use it:
CreateMethod(typeof(List<>), typeof(string));
NET - What is Type Forwarding in NET?
What is Type Forwarding in NET? - Type forwarding is a technique to move types from one assembly to another......
NET - What is SOAPFormatter? Explain how to serialize an object
What is SOAPFormatter? - It is an xml based serialization technique which is used to serialize and deserialize objects and data across networks.......
NET - Explain why we use XML Serialization
Explain why we use XML Serialization - Serialization allows persisting objects. XML serializations stores objects in form of XML which has become a storage standard......
Post your comment