-
Book Overview & Buying
-
Table Of Contents
C# 7 and .NET Core: Modern Cross-Platform Development - Second Edition
By :
Methods are often described as actions that an object can do. For example, a List class can add an item to itself or clear itself.
Events are often described as actions that happen to an object. For example, in a user interface, Button has a Click event, click being something that happens to a button.
Another way of thinking of events is a way of exchanging messages between two objects.
You have already seen the most common way to call or execute a method: use the dot syntax to access the method using its name. For example, Console.WriteLine tells the Console type to write out the message to the console window or terminal.
The other way to call or execute a method is to use a delegate. If you have used languages that support function pointers, then think of a delegate as being a type-safe method pointer. In other words, a delegate is the memory address of a method that matches the same signature as the delegate so that it can be safely...
Change the font size
Change margin width
Change background colour