.NET 反射应用
object request = null; string requestObjClassName = "命名空间" + 类型.ToString(); Type type = Type.GetType(requestObjClassName); object[] args = new object[] { objRequired, objAdditional }; RequestObj requestObj = null; try { requestObj = Activator.CreateInstance(type, args) as RequestObj; request = new object(dataContext, requestId, requestObj); } catch (Exception ex) { LoggerHelper.LogError(string.Format("Create request object failed {0}", requestType.ToString()), ex); throw ex; }