0
我想做的事情是這樣的:我用Google搜索在dotnet核心的運行時實現接口的最佳方式是什麼?
interface IMyInterface
{
void DoSomething();
string SaySomeWords(IEnumerable<string> words);
}
public class InterfaceImplFactory
{
public void RegisterInterface(Type type)
{
throw new NotImplementedException();
}
public InterfaceType GetInterfaceImpl<InterfaceType>()
{
throw new NotImplementedException();
}
}
class Program
{
static void Main(string[] args)
{
var factory = new InterfaceImplFactory();
factory.RegisterInterface(typeof(IMyInterface));
var impl = factory.GetInterfaceImpl<IMyInterface>();
impl.DoSomething();
impl.SaySomeWords(new List<string>() { "HelloWorld", "thanks"});
Console.ReadKey();
}
}
後如何在C#運行時實現一個接口,大部分文章都老了。我想通過使用lambda,dynamic但不排放來解決這個問題。有沒有像這樣的方法來解決這個問題?
感謝您的回覆,我貼了另一個問題更detailly [這裏](https://stackoverflow.com/questions/44993532/signature-of-the-body-and-declaration-in-a-method - 實施-DO-不匹配) –