需要反射时使用dynamic

//使用dynamic的写法
dynamic fileExplorerData = _currentFolder.FileExplorerData;
var data = fileExplorerData.InsertFromPath(newPath);

//使用反射的写法
MethodInfo InsertMethod = _currentFolder.FileExplorerData.GetType().GetMethod("InsertFromPath");
var fileExplorerData = InsertMethod.Invoke(_currentFolder.FileExplorerData, new object[] { newPath });
var data = fileExplorerData as FileExplorerData;
原文地址:https://www.cnblogs.com/xiaokang088/p/2848628.html