Using reflection to create an instance from string

Using reflection to create an instance from a string is pretty straightforward:

Type new Type = Type.GetType("Namespace.Location.ClassName, AssemblyName", true);

Very nice to use in combination with generic classes, something like this:

Public class Data < T > 
{
        private DataConntext  dataContext = new DataContext();

        public List< T > Getlist< T >()where T: class
        {
            return dataContext.CreateObjectSet< T >().ToList();
        }

}

You can use this for binding your grid, example:

       BindGrid(string table)
       {
         Type newType = Type.GetType("Namespace.Location" + table +", AssemblyName", true);
         Grid.datasource = new Data<newType>().GetList<newType>();
       }

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!