有人可以提炼成正确的英语为代表的是什么? [英] Can someone distill into proper English what a delegate is?

查看:95
本文介绍了有人可以提炼成正确的英语为代表的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以打破一个代表是成一个既有的目的和普遍利益的简单,短而简洁的解释是什么?我试图环绕此我的头,它只是没有在下沉。

Can someone please break down what a delegate is into a simple, short and terse explanation that encompasses both the purpose and general benefits? I've tried to wrap my head around this and it's just not sinking in.

推荐答案

在尽可能简单的术语,它本质上是一个指针的方法。

In the simplest possible terms, it's essentially a pointer to a method.

您可以有一个拥有委托类型(就像你有一个可以容纳一个int类型为int变量)的变量。您可以执行方法的代表点通过简单地调用您的变量一样的功能。

You can have a variable that holds a delegate type (just like you would have an int variable that can hold an int type). You can execute the method that the delegate points to by simply calling your variable like a function.

这可以让你具有不同的功能,就像你可能有变量数据。你的对象可以接受来自其他对象的代表,并呼吁他们,而不需要定义所有可能的功能本身。

This allows you to have variable functions just like you might have variable data. Your object can accept delegates from other objects and call them, without having to define all the possible functions itself.

这是非常方便的,当你想根据用户指定的标准对象做的事情。例如,过滤基于用户定义的真/假前pression列表。您可以让用户指定委托函数作为过滤器,以评估对每个列表项使用。

This comes in very handy when you want an object to do things based on user specified criteria. For example, filtering a list based on a user-defined true/false expression. You can let the user specify the delegate function to use as a filter to evaluate each list item against.

这篇关于有人可以提炼成正确的英语为代表的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆