How can I call generic method unknowing instance object type
问题 With this code: World w = new World(); var data = GetData<World>(w); If I get w with reflection and this can be of type World , Ambient , Domention , etc. How can I get GetData ??? I only have the instance object: var data = GetData<???>(w); 回答1: var type = <The type where GetData method is defined>; var genericType = typeof(w); var methodInfo = type.GetMethod("GetData"); var genericMethodInfo = methodInfo.MakeGenericMethod(genericType); //instance or null : if the class where GetData is