Essential C# 5.0 by Mark Michaelis & Eric Lippert
Author:Mark Michaelis & Eric Lippert [Michaelis, Mark & Lippert, Eric]
Language: eng
Format: epub
Publisher: Addison-Wesley
Published: 2013-08-26T22:00:00+00:00
* * *
class DelegateSample
{
// ...
static void Main(string[] args)
{
int i;
int[] items = new int[5];
for (i=0; i<items.Length; i++)
{
Console.Write("Enter an integer:");
items[i] = int.Parse(Console.ReadLine());
}
BubbleSort(items,
DelegateSample.__AnonymousMethod_00000000);
for (i = 0; i < items.Length; i++)
{
Console.WriteLine(items[i]);
}
}
private static bool __AnonymousMethod_00000000(
int first, int second)
{
return first < second;
}
}
* * *
In this example, the compiler transforms an anonymous function into a separately declared static method that is then instantiated as a delegate and passed as a parameter. Unsurprisingly, the compiler generates code that looks remarkably like the original code in Listing 12.7 that the anonymous function syntax was intended to streamline. However, the code transformation performed by the compiler can be considerably more complex than merely rewriting the anonymous function as a static method if “outer variables” are involved.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
NET | C & C++ Windows Programming |
SQL Server | VBA |
Visual Basic |
Deep Learning with Python by François Chollet(12592)
Hello! Python by Anthony Briggs(9928)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9803)
The Mikado Method by Ola Ellnestam Daniel Brolund(9787)
Dependency Injection in .NET by Mark Seemann(9348)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8310)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7772)
Grails in Action by Glen Smith Peter Ledbrook(7705)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7567)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7175)
Microservices with Go by Alexander Shuiskov(6943)
Practical Design Patterns for Java Developers by Miroslav Wengner(6858)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6801)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6424)
Angular Projects - Third Edition by Aristeidis Bampakos(6220)
The Art of Crafting User Stories by The Art of Crafting User Stories(5736)
NetSuite for Consultants - Second Edition by Peter Ries(5664)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5479)
Kotlin in Action by Dmitry Jemerov(5074)
