为什么试图理解代表感觉就像试图理解宇宙的本质?

编程入门 行业动态 更新时间:2024-10-23 19:35:06
本文介绍了为什么试图理解代表感觉就像试图理解宇宙的本质?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我读过两本书,有很多例子.他们对我来说仍然几乎没有意义.我可能会编写一些使用委托的代码,但我不知道为什么.我是唯一有这个问题的人,还是我只是个白痴?如果有人能真正向我解释我何时、何地以及为什么我会实际使用代理,我会永远爱你.

I've read two books, tons of examples. They still make next to no sense to me. I could probably write some code that uses delegates, but I have no idea why. Am I the only one with this problem, or am I just an idiot? If anyone can actually explain to me when, where, and why I would actually use a delegate, I'll love you forever.

推荐答案

委托只是在变量中传递函数的一种方式.

Delegates are just a way to pass around a function in a variable.

您传递一个委托函数来执行回调.比如在做异步 IO 的时候,你传递一个委托函数(一个你用委托参数写的函数),当数据从磁盘读取出来时,它会被调用.

You pass a delegated function to do a callback. Such as when doing asynchronous IO, you pass a delegated function (a function you have written with the delegate parameter) that will be called when the data has been read off the disk.

更多推荐

为什么试图理解代表感觉就像试图理解宇宙的本质?

本文发布于:2023-11-08 16:05:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569843.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:就像   宇宙   本质   感觉   代表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!