C guide programming

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

description

C guide programming

Transcript of C guide programming

C# GuideDelegates::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 defne callback methods. Delegates can be chained together; for example multiple methods can be called on asingle event. !ethods do not have to match the delegate signature exactly. "or more information see Covariance and ContravarianceCovariance and Contravariance in Delegates #C$ %rogramming &uide'.((( )xample:::delegate void Delegate1();delegate void Delegate2();static void method(Delegate1 d, Delegate2 e, System.Delegate f){// Compile-time error. //Cosole.!rite"ie(d ## e); // $% at compile-time. &alse if the r'-time type of f// is ot the same as that of d.System.Cosole.!rite"ie(d ## f);(((( )xample:::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 *isual +tudio Code )ditor.#pragma region name#pragma endregion comment