You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html>
<head>
<title>委托系列学习之委托基础</title>
</head>
<body>
<h1 id="section">委托系列学习之委托基础</h1>
<h2 id="section-1">委托概念</h2>
<p>百度百科:</p>
<blockquote>
<p>委托是一个类,它定义了方法的类型,使得可以将方法当作另一个方法的参数来进行传递。
这种将方法动态地赋给参数的做法可以避免在程序中大量使用If-Else(Switch)语句,同时使得程序具有更好的可扩展性。</p>
</blockquote>
<p>数据结构本质:</p>
<blockquote>
<p>委托和类一样,是一种用于封装命名或匿名方法的用户自定义引用类型。
委托和类同级,类表示数据集合,委托表示对一个或多个方法的引用,储存的是一系列具有相同参数和返回类型方法的地址列表,调用委托时,此委托列表的所有方法都将被执行。</p>
</blockquote>
<p>作用理解:</p>
<blockquote>
<p>委托是.net中函数回调机制的实现方式。
是函数指针在面向对象中的封装,
是面向对象的、类型安全的、可靠的函数指针。</p>
</blockquote>
<p>特点:</p>
<ul>
<li>面向对象</li>
<li>类型安全</li>
<li>可靠</li>
</ul>
</body>
</html>