Convert.ToSTring(dynamic动态类型) 运行时报错

异常信息:

The call is ambiguous between the following methods or properties: 'System.Convert.ToString(string)' and 'System.Convert.ToString(bool)'|栈  
at CallSite.Target(Closure , CallSite , Type , Object )




dynamic类型在运行时会确定类型,Convert.ToString()方法的时候应该会明确类型,为何会报不确定调用重载方法的异常?

请大佬提携~

https://img3.mukewang.com/5b9a195f00019cb613280196.jpg

慕村225694
浏览 1287回答 1
1回答

函数式编程

dynamic类型是在运行时确定类型,所以Convert.ToString(dynamic)时编译是可以通过的,但是当程序跑起来的时候Convert.ToString()函数接受的是确定类型的参数,是不能传入dynamic类型的。
打开App,查看更多内容
随时随地看视频慕课网APP