5 Ağustos 2010 Perşembe

Create Object at runtime

//Add this method to previous code im Programme class

private static Object createNewObject(string className)
{
Type objectType = Type.GetType(className);
Object newObject = Activator.CreateInstance(objectType);
return newObject;
}

// returns an object of spesified type as a given string parameter


// and you can calll this method as

Object newObj = createNewObject("Reflection.Employee");

// thats all..

1 yorum:

Adsız dedi ki...

http://www.podgoretsky.pri.ee/ftp/Docs/Cobol%20in%2021%20Days/index.htm