
对象表达式(F#)
http://msdn.microsoft.com/en-us/library/dd233237.aspx
定义:
An object Expression is an Expression that creates a new instance of a
dynamically created,anonymous object type that is based on an
existing base type,interface,or set of interfaces.
我想知道,C#中是否存在类似的东西?
或者这些东西只能用F#编程语言?
匿名类型无法符合接口或从任何东西派生.
Lambdas和delegates提供函数作为变量.
Object Expressions的文档声明了这一点,这使它听起来像语言方便.
You use object Expressions when you want to avoID the extra code and
overhead that is required to create a new,named type. If you use
object Expressions to minimize the number of types created in a
program,you can reduce the number of lines of code and prevent the
unnecessary proliferation of types. Instead of creating many types
just to handle specific situations,you can use an object Expression
that customizes an existing type or provIDes an appropriate
implementation of an interface for the specific case at hand.
你可以用这样的东西伪造它(虽然你不能将它限制在一个接口)
var foo = new { square = new Func<int,int>(x => x * x) }; 总结 以上是内存溢出为你收集整理的C#中的“对象表达”是否存在于F#中?全部内容,希望文章能够帮你解决C#中的“对象表达”是否存在于F#中?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)