Sunteți pe pagina 1din 1

C# Guide

Delegates::
Delegates have the following properties:

Delegates are like C++ function pointers but are type safe.

Delegates allow methods to be passed as parameters.

Delegates can be used to define callback methods.

Delegates can be chained together; for example, multiple methods can be called on a
single event.

Methods do not have to match the delegate signature exactly. For more information,
see Covariance and ContravarianceCovariance and Contravariance in Delegates
(C# Programming Guide).

/// Example:::

delegate void Delegate1();


delegate void Delegate2();
static void method(Delegate1 d, Delegate2 e, System.Delegate f)
{
// Compile-time error.
//Console.WriteLine(d == e);
// OK at compile-time. False if the run-time type of f
// is not the same as that of d.
System.Console.WriteLine(d == f);
}

/// Example:::

Regions in C:::
#pragma region lets you specify a block of code that you can expand or collapse when
using the outlining feature of the Visual Studio Code Editor.
#pragma region name
#pragma endregion comment

S-ar putea să vă placă și