有人可以提炼出适当的英语代表是什么吗?

Can someone distill into proper English what a delegate is?(有人可以提炼出适当的英语代表是什么吗?)
本文介绍了有人可以提炼出适当的英语代表是什么吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以将代表的含义分解为一个简单、简短、简洁的解释,同时包含目的和一般利益吗?我试着把我的头绕在这个问题上,但它并没有陷入困境.

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.

当您希望对象根据用户指定的条件执行操作时,这非常方便.例如,根据用户定义的真/假表达式过滤列表.您可以让用户指定委托函数以用作过滤器来评估每个列表项.

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.

这篇关于有人可以提炼出适当的英语代表是什么吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)