c# - 类型反射中的重复项目(?)

标签 c# reflection types

鉴于以下代码,为什么我会得到重复的项目?

Type intType = typeof(Int32);
foreach(var v in intType.GetMethods())
Console.WriteLine(v.Name);

例如 ToString() 出现了 4 次。

最佳答案

因为 Int32.ToString() has four overloads .您可以通过设置断点并检查 intType.GetMethods() 结果轻松看到这一点,您将在其中看到(以及其他):

[5] {System.String ToString()}
[6] {System.String ToString(System.String)}
[7] {System.String ToString(System.IFormatProvider)}
[8] {System.String ToString(System.String, System.IFormatProvider)} 

关于c# - 类型反射中的重复项目(?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15550913/

相关文章:

c# - EF Core - NodaTime 类型的脚手架?

委托(delegate)上的 C# 解析器错误?

Haskell:以字符串形式获取数据构造函数名称

c - int 如何等于另一个返回 long int 的函数?

reactjs - 如何在react js中检查 Material ui主题的类型? (浅色或深色)

c# - JSON.NET 反序列化/序列化 JsonProperty JsonObject

c# - HTTP 客户端未对代理服务器 C# 进行身份验证

c# - 如何获得带有命名空间和类名的方法名?

c# - 在 C# 中,如何使用反射访问花括号构造函数?

c++ - 数组是一种数据类型吗?