当前位置:首页 > 英文周记 > 正文内容

delegates「delegates from」

更新时间:2026-07-18 03:54:24 周记网3年前 (2023-03-20)英文周记97

delegate的形容词形式

形容词

delegates,从名词转换成形容词

举例:XXXX

delegates「delegates from」

sent

a

delegates

party

to

participate

in

a

peace

talk.

多delegate人数的队伍。

有时候,用delegate

party也行。

形容词

delegating,从动词转换成形容词

举例:

The

command

post

assigns

a

delegating

party

to

assume

the

role

of

dealing

with

strangers

crossing

the

border.

-

附有代表作用的团队

形容词

delegated,以过去动词充当形容词

举例:

The

manager

is

executing

his

delegated

actions

posted

to

him.

-

受委任的行动

Delegate是什么,举例说明!

Delegate是什么?

对微软来说,一个delegate声明指定了一个相关的类型,你可以使用这一类型来封装一个含有特定标记的方法。一个delegate实例可以封装一个静态或一个实例方法。概略的说,Delegates就好象是C++中的函数指针;然而,delegates属于安全和保护类型。

我的采访是通过**进行,所以我可以很容易和轻松地阐述这些定义。透明和详尽的解释是有必要的。然而,更贴切delegates的定义是,即使在没有对目标对象(target object)有任何了解的情况下,也可以随时使用一些方法,这样的方法即为delegates。很多开发人员通常将它们说成回调函数(callback functions)。现在让我们看一个范例,以更好理解它的应用。

使用中的Delegates

我们的范例程序开始于两个简单的C#类,这两个类包含一个方法以通过控制台来显示信息:

public class DelegateClass1 {

public void exampleMethod1(String passedString) {

Console.WriteLine(passedString); }

}

public class DelegateClass2 {

public void exampleMethod2(String passedString) {

Console.WriteLine(passedString); }

}

请注意到,这两个类执行类似的方法。这些方法具有不同的名称,但它们的标记和实体都相同。你可以使用一个delegate来结合这两个方法,实现过程是通过定义一个从这两个方法的通常特性中抽象出新的数据类型。也就是,它们都将一个简单的字符作为一个变量并返回void。C# delegate关键词使得这些变成可能:

public delegate void example(String passedString);

例如,使用这一新的数据类型声明,我们可以通过一个通常的抽象来调用这两个方法。下面的C#控制台程序利用了我们的delegate范例来调用这两个类的方法:

public class TestExampleDelegate {

public delegate void example(String passedString);

public static void Main(string[] args) {

example[] items = new example[2];

items[0] = new example(new DelegateClass1().exampleMethod1);

items[1] = new example(new DelegateClass2().exampleMethod2);

for(int i = 0; i items.Length; i++) {

items[i]("Builder.com Rules!");

} } }

以上代码建立了一个数组的范例对象,并使用这些类中的方法实例化这些对象。由于忽略了括号,范例对象被一个调用方法处理。代码的执行结果显示了文本中。

(注意:Delegates不属于C#的细节;它们是.NET Framework的标准部分,所以你可以使用其它的语言,比如VB.NET或者J#。)

在任何地方都可以使用Delegates

在这一点上,也许你只知道有这样一回事,但却没有察觉它在你的程序中的应用。虽然你没有建立自己的delegates,但如果经常使用事件时你会使用到它们。一个极好的例子就是ASP.NET中使用的事件。在后台使用的Delegates围绕着事件工作。事件使用一个标记,你也可以在一个线程结构中找到delegates。

接口(interface)

你必须注意的另一个点是一个delegate和一个接口之间的相似性,因为它们都将规范和执行分离开来。它们允许开发人员建立与规范相符合的执行。除此之外,方法标记必须是被指定和相兼容。

所以,你什么时候使用接口?以及你什么时候使用delegates?微软提供了以下的指导思想。

在以下情况下使用Delegates很有用:

调用一个单一方法。

一个类要进行方法规范(method specification)的多种执行。

使用一个静态方法来执行规范。

想获得类似事件设计的模式。

调用者没有必要知道或获得方法定义的对象。

执行的提供者想将规范的执行“分发”成一些选择性的部分。

在以下情况下使用接口非常有好处:

规范指定一套即将被调用的方法。

特别的,一个类只执行规范一次。

接口的调用者想通过接口类型以获得其它接口或类。

Trackback:

日入一词_55:delegate

Grid Views delegate much of their functionality to specially designed helper objects and provide a number of objects that store grid View settings so that these settings are logically organized.

noun /'dɛlɪɡət/

1

Around 350 delegates attended the conference.

the U.N. delegates from African countries

He's been chosen as a delegate to the convention.

The conference was attended by delegates from 56 countries.

Delegates have voted in favour of the motion.

Each union elects several delegates to the annual conference.

verb  /ˈdɛlɪɡet/

1

A good manager knows when to delegate.

It takes experience to judge correctly how much power should be delegated.

delegate something to somebody

Minor tasks should be delegated to your assistant.

A manager should delegate authority to the best employees.

Those chores can be delegated to someone else.

He doesn't delegate very well.

Some managers find it difficult to delegate.

The job had to be delegated to an assistant.

As a boss you have to delegate (responsibilities to your staff).

Authority to make financial decisions has been delegated to a special committee.

Because Henry hated to delegate, he was always overworked.

He always delegates boring tasks to his assistant.

He talks of travelling less, and delegating more authority to his deputies in Britain and Australia...

How many of their activities can be safely and effectively delegated to less trained staff?...

Many employers find it hard to delegate.

delegation noun

A key factor in running a business is the delegation of responsibility.

2

delegate somebody to do something

I was delegated to find a suitable/'sutəbl/ conference venue.

He was delegated by the town to take care of the monument.

I've been delegated to organize the Christmas party.

A group of four teachers were delegated to represent the school at the union conference.

Bill was delegated to fetch the manager.

Officials have now been delegated to start work on a draft settlement.

代表团成员的英文怎么说

delegate 英[ˈdelɪgət] 美[ˈdɛlɪˌɡet]

n. 代表,代表团成员;

vt. 委派代表; 授权给; [法律] 债务转移;

[例句]He plans to delegate more authority to his deputies

他打算把更多的权力交给副手。

[其他] 第三人称单数:delegates 复数:delegates 现在分词:delegating过去式:delegated 过去分词:delegated

标签: delegates

“delegates「delegates from」” 的相关文章

delegates「Delegates大写」

delegates「Delegates大写」

代表团成员的英文怎么说 delegate 英[ˈdelɪgət] 美[ˈdɛlɪˌɡet] n. 代表,代表团成员; vt. 委派代表; 授权给; [法律] 债务转...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。