I m 采用反射方法,用一种在操作时间确定的通用方法。 我的法典如下:
Type tType = Type.GetType(pLoadOut.Type);
MethodInfo method = typeof(ApiSerialiseHelper).GetMethod("Deserialise", new Type[] { typeof(string) });
MethodInfo generic = method.MakeGenericMethod(tType);
generic.Invoke(obj, new object[] { pLoadOut.Data });
.。 然而,一般而言。 Invoke方法将物体退回,但我喜欢的是操作时间确定的类型。 这种做法是否可行,或者是否有更好的选择?
标记