如果我搜索过,我肯定会得到一个显示什么是委托和行动的例子.我已经阅读了基本书籍,给出了代表的例子.
但我想知道的是它们在现实世界中的应用.请不要给Hello World示例或动物类它们太基本了
例如:
我一直试图在C#中找到代表,但我似乎没有明白使用它们.以下是来自代表MSDN页面的一些稍微重建的代码:
using System;
using System.Collections;
namespace Delegates
{
// Describes a book in the book list:
public struct Book
{
public string Title; // Title of the book.
public string Author; // Author of the book.
public decimal Price; // Price of the book.
public bool Paperback; // Is it paperback?
public Book(string title, string author, decimal price, bool paperBack)
{
Title = title;
Author = author;
Price = price;
Paperback = paperBack;
}
}
// Declare a …Run Code Online (Sandbox Code Playgroud)