C# 需要哪些类型?
C# 的某些功能需要特定类型(“该类型必须实现 System.IDisposable
”)。其他功能基于模式(“任何看起来像带有正确签名的 Select()
方法”的类型)。
C# 需要从库中获取的最小类型集是什么(上面的前一种情况)?这与 VB.NET 和 F# 等其他语言有何不同?
Possible Duplicate:
Which parts of C# .NET framework are actually parts of the language?
There are some features of C# that require specific type (“the type has to implement System.IDisposable
”). Other features are based on patterns (“any type that has something that looks like a method called Select()
with the proper signature”).
What is the minimum set of types that C# requires from the library (the former case above)? How does that differ from other languages like VB.NET and F#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IDisposable 是一个接口,.Net 提供接口作为开发基于契约的 API 的手段,而不是依赖于具体的类。例如,它可以让你说,“任何类型,只要它有一个名为 Dispose() 的方法”。
这与 C# 类型系统和原始类型没有太大关系。
IDisposable is an interface, .Net provivdes interfaces as a means to develop contract based APIs rather than relying on concrete classes. Eg, It lets you say, 'any type as long as it has a method called Dispose()'
This is nothing much to do with the C# type system nor it's primitive types.