Delegado, Eventos en C#

Share Embed Donate


Short Description

Download Delegado, Eventos en C#...

Description

Contenido Delegados (Guía de programación de C#) ...................................................................................................... 3 Delegate (Clase) ........................................................................................................................................................................ 4 Utilizar delegados (Guía de programación de C#) .................................................................................................................... 7 Cuándo se utilizan delegados en lugar de interfaces (Guía de programación de C#) ........ ................. .................. ................... ................... .................. ............... ...... 10 Delegados con méto dos con nombre y delegados con métodos anónimos (Guía de programación de C#) .......... ................... ............... ...... 10 Métodos anónimos (Guía de programación de C#) ................................................................................................................ 12 Covarianza y contravarianza en los delegados (Guía de programación de C#) ..................... .............................. ................... ................... .................. .................. ............ ... 14 Cómo: Combinar delegados deleg ados (delegados de multidifusión) m ultidifusión) (Guía de programación de C#)......... .................. .................. ................... ................... ............... ...... 16 Cómo: Declarar un delegado, crear instancias del mismo y utilizarlo (Guía de programación de C#) ......... .................. .................. ................. ........ 17 EventHandler (Delegado) ........................................................................................................................................................ 21 EventArgs Event Args (Clase) ................................... .................. ................................... ................................... ................................... ................................... ................................... ................................... ................................... ......................... ....... 23

Eventos (Guía de programación de C#) ......................................................................................................... 25 Cómo: Suscribir y cancelar la suscripción a eventos (Guía de programación de C#) ......... .................. .................. .................. .................. .................. ................. ........ 26 Cómo: Publicar eventos que cumplan las directrices de .NET Framework (Guía de programación de C#) ......... .................. .................. .........29 Cómo: Producir eventos de una clase base en clases derivadas (Guía de programación de C#) ................... ............................ .................. ............... ...... 32 Cómo: Implementar eventos de interfaz (Guía de programación de C#) .......... .................... ................... .................. .................. .................. .................. .................. .............. ..... 35 Sincronización de subprocesos (Guía de programación de C#) ...................... ............................... ................... ................... .................. .................. .................. .................. ................. ........ 39 Cómo: Utilizar un diccionario para almacenar instancias de eventos (Guía de programación de C#) .............. ....................... .................. ............ ... 43 Cómo: Implementar descriptores de acceso de eventos personalizados perso nalizados (Guía de programación de C#) ....................... ............................. ...... 45 Ejemplo de eventos ................................................................................................................................................................. 45 Diseño de eventos ................................................................................................................................................................... 47

Controlar y provocar eventos................................................................................................................................ 48 Eventos y delegados ................................................................................................................................................................ 49 Cómo: Conectar métodos controlador de eventos a eventos ..................... .............................. ................... ................... .................. .................. .................. .................. .................. ........... .. 51 Para agregar un método controlador de eventos para un evento ....................... ................................ .................. .................. .................. ................... ................... ............ ... 51 Utilizar eventos ....................................................................................................................................................................... 51 Cómo: Consumir eventos en una aplicación de formularios We b Forms .......... .................... ................... .................. .................. .................. .................. .................. .............. ..... 55 Para controlar un evento de clic de botón en una página Web ......... .................. .................. .................. .................. .................. .................. ................... ................... ............ ... 55 Cómo: Consumir eventos en una aplicación de formularios Windows Forms ........................ ................................. .................. .................. .................. .................. ........... .. 57 Para controlar un evento de clic de un botón en un formulario Windows Forms ........ ................. .................. ................... ................... .................. ............ ... 57 Provocar un evento ................................................................................................................................................................. 59

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Cómo: Implementar eventos en una clase ............................................................................................................................. 60 Para implementar un evento sin datos específicos del evento ......................... .................................. .................. .................. .................. ................... ................... ............... ...... 60 Para implementar un evento con datos específicos del evento .................. ........................... .................. .................. .................. .................. ................... ................... ............ ... 61 Cómo: Provocar y utilizar eventos .......................................................................................................................................... 62 Provocar múltiples eventos ..................................................................................................................................................... 66 Cómo: Controlar varios eventos mediante propiedades de eventos .......................... ................................... .................. .................. .................. .................. .................. .............. ..... 67 Para controlar varios var ios eventos mediante las propiedades de evento ........ .................. ................... .................. .................. .................. .................. .................. .............. ..... 67 Cómo: Declarar eventos que evitan que se pierda memoria ......... .................. .................. .................. .................. .................. .................. ................... ................... .................. ............... ...... 68 Cómo: Controlar varios eventos mediante propiedades de eventos .......................... ................................... .................. .................. .................. .................. .................. .............. ..... 69 Para controlar varios var ios eventos mediante las propiedades de evento ........ .................. ................... .................. .................. .................. .................. .................. .............. ..... 69

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Delegados (Guía de programación de C#) Un delegado es un tipo que define una firma de método y se puede pu ede asociar a cualquier método con una firma compatible. Puede invocar (o llamar) al método a través del delegado. Los delegados se utilizan para pasar métodos como argumentos a otros métodos. Los controladores de eventos no son más que métodos que se invocan a través de delegados. Cree un método p ersonalizado y una clase como un control de Windows podrá llamar al método cuando se produzca un determinado evento. En el siguiente ej emplo se muestra la declaración de un delegado: public delegate int PerformCalculation(int PerformCalculation(int x, int y);

Cualquier método de cualquier clase o estructura accesible que coincida con la firma del delegado, la cual está compuesta por los parámetros y el tipo de valor devuelto, puede asignarse al delegado. El método puede ser un método estático o un método de instancia. Esto permite el cambio mediante programación programación de las llamadas a métodos y la incorporación de nuevo código en las clases existentes. Si conoce la firma del delegado, puede asignar su propio método. Nota: En el contexto de la sobrecarga de métodos, la firma de un método no i ncluye el valor devuelto. Sin embargo, en el contexto de los delegados, la firma sí incluye el valor devuelto. En otras palabras, un método debe tener el mismo valor devuelto que el delegado.

Esta capacidad para hacer referencia a un método como parámetro hace que los delegados sean idóneos para definir métodos de devolución de llamada. Por ejemplo, un algoritmo d e ordenación se podría pasar como referencia al método que compara dos objetos. La separación del código de comparación permite programar el algoritmo de forma más general. Información general sobre delegados

Los delegados tienen las propiedades siguientes:    





Los delegados son similares a los punteros a función de C++, pero poseen seguridad de tipos. Los delegados permiten pasar los métodos como parámetros. Los delegados pueden utilizarse para definir métodos de devolución de ll amada. Los delegados pueden encadenarse; por ejemplo, se puede llamar a varios métodos en un solo evento. No es necesario que los métodos coincidan exactamente con la firma de delegado. Para obtener más información, vea Covariance and ContravarianceCovarianza ContravarianceCovarianza y contravarianza en los delegados (Guía de programación de C#). C#) . La versión 2.0 de C# introdujo el concepto de métodos anónimos, anónimos, los cuales permiten pasar bloques de código como parámetros en lugar de utilizar métodos definidos i ndependientemente. C# 3.0 introdujo las expresiones lambda como una manera más concisa de escribir bloques de códigos insertados. Tanto los métodos anónimos como las expresiones lambda (en ciertos contextos) se

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

  

   

Utilizar delegados (Guía de programación de C#) Cuándo se utilizan delegados en lugar de interfaces (Guía de programación de C#) Delegados con métodos con nombre y delegados con métodos anónimos (Guía de programación de C#) Métodos anónimos (Guía de programación de C#) Covarianza y contravarianza en los delegados (Guía de programación de C#) Cómo: Combinar delegados (delegados de multidi fusión) (Guía de programación de C#) Cómo: Declarar un delegado, crear instancias del mismo y utilizarlo (Guía de programación de C#)

Delegate (Clase) Representa un delegado, que es una estructura de datos que hace referencia a un método estático o a una instancia de clase y a un método de d e instancia de dicha clase. Espacio de nombres: System Ensamblado: mscorlib (en mscorlib.dll) Sintaxis [SerializableAttribute] [ClassInterfaceAttribute(ClassInter [ClassInterfaceAttribute(ClassInterfaceType.AutoDua faceType.AutoDual)] l)] [ComVisibleAttribute(true [ComVisibleAttribute( true)] )] public abstract class Delegate : ICloneable, ISerializable Comentarios

La clase Delegate es la clase base para los ti pos de delegado. No obstante, el sistema y l os compiladores son los únicos que pueden derivar explícitamente a partir de la clase Delegate o de la clase MulticastDelegate.. Tampoco está permitido derivar un tipo nuevo a partir de un tipo de delegado. La clase MulticastDelegate Delegate no se considera un tipo de delegado; es una clase que se utiliza para derivar tipos de delegado. La mayoría de los lenguajes implementan una palabra clave delegate y los compiladores de dichos lenguajes pueden derivar a partir de la clase MulticastDelegate MulticastDelegate;; por lo tanto, los usuarios deben emplear la palabra clave delegate que proporciona el lenguaje. Además de los métodos heredados, Common Language Runtime proporciona dos métodos especiales para los tipos de delegado: BeginInvoke y EndInvoke. Para obtener más in formación sobre estos métodos, vea Llamar a métodos sincrónicos de forma asincrónica asincrónica.. La declaración de un tipo de delegado establece un contrato que especifica la firma de uno o varios métodos. Un delegado es una instancia de un tipo de delegado que contiene referencias a:  

Un método de instancia de un tipo ti po y un objeto de destino asignable a ese tipo. Un método de instancia de un tipo, ti po, con el parámetro this oculto expuesto en la lista de parámetros formales. Se dice que el delegado es un delegado de instancia abierto.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Nota: En las versiones 1.0 y 1.1 de .NET Framework, un delegado sólo puede representar un método si la firma del método coincide exactamente con la firma que especifica el tipo de delegado. Por tanto, sólo se admiten los puntos primero y tercero de la anterior l ista y, en el caso del primero, es necesaria una coincidencia exacta de tipos.

Cuando un delegado representa un método de instancia cerrado en su primer argumento (el caso más habitual), el delegado almacena una referencia al punto de entrada del método y una referencia a un objeto, el objeto de destino, que es de un tipo asignable al tipo que define el método. Cuando un delegado representa un método de instancia abierto, almacena una referencia al punto de entrada del método. La firma del delegado debe incluir el parámetro this oculto en su lista de parámetros formales; en este caso, el delegado no tiene una referencia a un objeto de destino, por lo que se debe d ebe proporcionar un objeto de destino al invocar al delegado. Cuando un delegado representa un método estático, el delegado almacena una referencia al punto de entrada del método. Cuando un delegado representa un método estático cerrado en su primer argumento, el delegado almacena una referencia al punto de entrada del método y una referencia a un objeto de destino asignable al tipo del primer argumento del método. Al invocar al delegado, del egado, el primer argumento del método estático recibe el objeto de destino. d estino. La lista de invocaciones de un delegado es un conjunto ordenado de delegados donde cada elemento de la lista invoca exactamente a uno de los métodos representados por el delegado. Una lista de invocaciones puede contener métodos duplicados. Durante una invocación, los métodos se llaman en el orden en que aparecen en la lista de invocaciones. Un delegado intenta invocar a todos los métodos de la lista de invocaciones; se invoca a los duplicados una vez por cada aparición en la lista de i nvocaciones. nvocaciones. Los delegados son inmutables; una vez creados, la lista de invocaciones de un delegado no cambia. Se dice que los delegados son de multidifusión y combinables, porque un delegado puede invocar uno o varios métodos y se puede pu ede utilizar para combinar operaciones. Las operaciones de combinación, como Combine y Remove Remove,, no modifican los delegados existentes. En lugar de ello, una operación de este tipo ti po devuelve un nuevo delegado que contiene los l os resultados de la operación, un delegado sin modificar o null. Una operación de combinación devuelve null cuando el resultado de la operación es un delegado que no hace referencia a un método como mínimo. Una operación de combinación devuelve un delegado sin modificar cuando la operación solicitada no tiene efecto. Si un método invocado produce una excepción, el método deja d e ejecutarse, la excepción se pasa de nuevo al llamador del delegado y no se invoca al resto de los métodos de la lista de invocaciones. Aunque la excepción se detecte en el llamador, este comportamiento no cambia. Cuando la firma de los métodos invocados por un del egado incluye un valor devuelto, el delegado devuelve el valor devuelto del último úl timo elemento de la lista de invocaciones. Cuando la firma incluye un parámetro que se pasa por referencia, el valor final del parámetro es el resultado que se obtiene después de que cada

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Ejemplos

En el ejemplo siguiente se muestra la l a forma de definir un delegado denominado myMethodDelegate. Las instancias de este delegado se crean para un método de i nstancia y un método estático de la clase mySampleClass anidada. El delegado correspondiente correspondiente al método de instancia requiere una instancia de mySampleClass. La instancia de mySampleClass se guarda en una variable denominada mySC. using System; public class SamplesDelegate {  // Declares a delegate for for a method that takes in an int and returns returns a String. public delegate String myMethodDelegate( int myInt );  // Defines some methods to which the delegate can can point. public class mySampleClass {  // Defines an instance instance method. public String myStringMethod ( int myInt ) { if (( myInt > 0 ) if  return(( "positive" ); return if (( myInt < 0 ) if  return(( "negative" ); return return ( "zero" ); }  // Defines a static method. method. public static String mySignMethod ( int myInt ) { if (( myInt > 0 ) if  return(( "+" ); return if (( myInt < 0 ) if  return(( "-" ); return return ( "" ); } } public static void Main() {  // Creates one delegate for each method. For the instance method, an  // instance (mySC) (mySC) must be supplied. For For the static method, use the  // class name. mySampleClass mySC = new mySampleClass(); myMethodDelegate myD1 = new myMethodDelegate( mySC.myStringMethod ); myMethodDelegate myD2 = new myMethodDelegate( mySampleClass.mySignMethod );  // Invokes the delegates. delegates. Console.WriteLine( "{0} is {1}; use the sign \"{2}\"." \"{2}\".",, 5, myD1( 5 ), myD2( 5 ) ); Console.WriteLine( "{0} is {1}; use the sign \"{2}\".", \"{2}\".", -3, myD1( -3 ), myD2( -3 ) ); Console.WriteLine( "{0} is {1}; use the sign \"{2}\"." \"{2}\".",, 0, myD1( 0 ), myD2( 0 ) ); }

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

5 is positive; use the sign "+". -3 is negative; use the sign "-". 0 is zero; use the sign "". */

Jerarquía de herencia System.Object System.Delegate System.MulticastDelegate Seguridad para subprocesos Todos los miembros static (Shared en Visual Basic) públicos de este ti po son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Utilizar delegados (Guía de programación de C#) Un delegado es un tipo de objeto que encapsula un método de forma segura, similar a un puntero a función de C y C++. A diferencia di ferencia de los punteros a función de C, los d elegados están orientados a objetos, proporcionan seguridad de tipos y son seguros. El tipo de un delegado se define por su nombre. El ejemplo siguiente declara un delegado denominado Del que puede encapsular un método que toma un valor string como argumento y devuelve un valor void void:: public delegate void Del(string Del(string message);

Generalmente, un objeto de delegado se crea proporcionando el nombre del método que el delegado contendrá o con un método anónimo. anónimo. Una vez que se crean instancias de un delegado, el delegado pasará al método una llamada realizada por éste al delegado. Los parámetros que el llamador pasó al delegado se pasan al método y el delegado del egado devuelve al llamador el valor devuelto del método, si hay alguno. Esto se conoce como invocar al delegado. Se puede invocar un delegado con i nstancias como si fuera el propio método contenido. Por ejemplo:

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

delegado con instancias es un objeto, puede pasarse como parámetro o asignarse a una propiedad. Esto permite que un método acepte un delegado como parámetro y l lame al delegado posteriormente. Esto se conoce como devolución de llamada asincrónica y constituye un método común de notificación de un llamador cuando ha finalizado un proceso largo. Cuando se utiliza un delegado de esta forma, no es necesario que el código que utiliza el delegado conozca la implementación del método que se está utilizando. La funcionalidad es similar simil ar a la encapsulación encapsulación que proporcionan las i nterfaces. Para obtener más información, vea Cuándo se utilizan delegados en lugar de interfaces (Guía de programación de C#). C#) . Otro uso común de devoluciones de llamada es definir un método de comparación personalizado y pasar ese delegado a un método de ordenación. Esto permite al código del llamador ser parte del algoritmo de ordenación. El método del ejemplo siguiente utili za el tipo Del como parámetro: public void MethodWithCallback( MethodWithCallback(int int param1, int param2, Del callback) { callback("The callback("The number is: " + (param1 + param2).ToString()); param2).ToString()); } A continuación, se puede pasar el delegado creado anteriormente a ese método: MethodWithCallback(1, 2, handler);

y recibir el resultado siguiente en la l a consola: The number is: 3 Al utilizar el delegado como abstracción, MethodWithCallback no es necesario llamar a la consola directamente; es decir, el delegado no se tiene ti ene que diseñar pensando en una consola. Lo que MethodWithCallback hace es simplemente preparar una cadena y pasarla a otro método. Esto es especialmente eficaz, puesto que un método delegado puede utilizar cualquier número de parámetros. Cuando se crea un delegado para contener un método de instancia, el delegado hace referencia tanto a la instancia como al método. Un delegado no conoce el tipo de instancia a parte del método que éste contiene, de modo que un delegado del egado puede hacer referencia a cualquier tipo de objeto siempre que exista un método en dicho objeto que coincida con la firma del delegado. Cuando se crea un delegado para contener un método estático, éste sólo hace referencia al método. Considere l as siguientes declaraciones: public class MethodClass

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

 //Both types of assignment assignment are valid. valid. Del allMethodsDelegate = d1 + d2; allMethodsDelegate += d3;

En este momento, allMethodsDelegate contiene tres métodos en su lista de i nvocación: Method1, Method2 y DelegateMethod. Los tres delegados originales, d1, d2 y d3 no cambian. Cuando se invoca a allMethodsDelegate, se llama a los tres métodos por orden. Si el delegado utiliza parámetros de referencia, ésta a su vez se pasa secuencialmente a cada uno de los tres métodos y todos los cambios efectuados por un método son visibles para el siguiente método. Cuando alguno de los métodos produce una excepción que no se detecta dentro del método, esa excepción se pasa al llamador del delegado y no se llama a ninguno de los métodos siguientes de la l a lista de invocación. Si el delegado tiene un valor devuelto y/o fuera de los parámetros, devuelve el valor devuelto y l os parámetros del último método invocado. Para quitar un método de la lista de invocación, utilice el operador de resta o de asignación de resta ('-' o '-='). Por ejemplo:  //remove Method1 allMethodsDelegate -= d1;  // copy AllMethodsDelegate while removing d2 Del oneMethodDelegate = allMethodsDelegate - d2;

Puesto que los tipos de delegados se derivan de System.Delegate, los métodos y las propiedades definidos por esa clase se pueden llamar en el delegado. Por ejemplo, para buscar el número de métodos en la lista de invocación de un delegado, puede escribir: int invocationCount = d1.GetInvocationList().GetLength(0) d1.GetInvocationList().GetLength(0);;

Los delegados con más de un método en su lista de invocación derivan de MulticastDelegate MulticastDelegate,, que es una subclase de System.Delegate. El código anterior funciona en ambos casos porque las d os clases admiten GetInvocationList. Los delegados de multidifusión se utilizan ampliamente en el control de eventos. Los objetos de origen de eventos envían notificaciones de eventos a objetos de destinatario registrados para recibir ese evento. Para registrar un evento, el destinatario crea un método diseñado para controlar el evento, a continuación crea un delegado para dicho método y pasa al delegado al origen de eventos. El origen llama ll ama al delegado cuando se produce el evento. Luego el delegado llama al método de control de eventos del destinatario y

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

System.Console.WriteLine(d == f); }

Cuándo se utilizan delegados en lugar de interfaces (Guía de programación de C#) Tanto los delegados como las interfaces permiten a un diseñador de clases separar las declaraciones y las implementaciones de los tipos. Una interfaz determinada puede ser heredada e implementada por cualquier clase o estructura estructura.. Se puede crear un delegado para un método en cualquier clase, con tal de que el método se ajuste a la firma de d e método para el delegado. Cualquier objeto puede utili zar una referencia de interfaz o un delegado sin tener conocimiento alguno sobre l a clase que implementa el método de interfaz i nterfaz o delegado. Según estas similitudes, ¿cuándo debería un diseñador de clases utilizar un delegado y cuándo una interfaz? Utilice un delegado cuando:   

 

Se utilice un modelo de diseño de eventos. Se prefiere a la hora de encapsular un método estático. El autor de las llamadas no tiene ninguna necesidad de obtener acceso a otras propiedades, métodos o interfaces en el objeto que implementa i mplementa el método. Se desea conseguir una composición sencilla. Una clase puede necesitar más de una implementación del método.

Utilice una interfaz cuando:    

Haya un grupo de métodos relacionados a los que se pueda ll amar. Una clase sólo necesita una implementación del método. La clase que utiliza la interfaz deseará convertir esa interfaz en otra interfaz o ti pos de clase. El método que se va a implementar está vinculado al tipo o identidad de la clase; por ejemplo, métodos de comparación.

Un buen ejemplo del uso de una interfaz de método único en lugar de un delegado es IComparable o la versión genérica, IComparable IComparable.. IComparable declara el método CompareTo CompareTo,, que devuelve un entero que especifica una relación menor que, igual que o mayor que entre dos objetos del mismo tipo. ti po. IComparable se puede utilizar como base de un algoritmo de ordenación. Aunque utilizar un método de comparación delegado como la base de un algoritmo de ordenación sería válido, no es lo ideal. Lo ideal es

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

 // Instantiate the delegate delegate using the method as a parameter: Del d = obj.DoWork; Esto se denomina utilizar un método con nombre. Los delegados creados con un método con nombre pueden encapsular un método estático o un método de instancia. Los métodos con nombre son la única forma de crear instancias de un delegado en versiones anteriores de C#. Sin embargo, en una situación en la que crear un método nuevo constituye una sobrecarga no deseada, C# permite crear instancias de un delegado y especificar inmediatamente un bloque de código que el delegado procesará cuando se le llame. El bloque puede contener una expresión lambda o un método anónimo. Para obtener más información, vea Funciones anónimas (Guía de programación de C#) . Comentarios

El método, que se pasa como parámetro de delegado, debe tener la misma firma que la declaración de delegado. La instancia de un delegado puede encapsular un método estático o de instancia. Aunque el delegado puede utilizar un parámetro out out,, no se recomienda su uso con delegados de eventos de multidifusión porque no se puede saber a qué del egado se va a llamar. Ejemplo 1

El siguiente es un ejemplo sencillo de declaración y uso de un delegado. Observe que tanto el delegado, Del, como el método asociado, MultiplyNumbers, tienen la mi sma firma  // Declare a delegate delegate void Del(int Del(int i, double j); class MathClass { static void Main() { MathClass m = new MathClass();  // Delegate instantiation using using "MultiplyNumbers"

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

} }  /* Output: Invoking the delegate using 'MultiplyNumbers': 2 4 6 8 10 */

Ejemplo 2

En el siguiente ejemplo, un delegado se asigna a métodos estáticos y de instancia y devuelve i nformación específica de cada uno de ellos.  // Declare a delegate delegate void Del(); class SampleClass { public void InstanceMethod() { System.Console.WriteLine("A System.Console.WriteLine( "A message from the instance i nstance method."); method."); } static public void StaticMethod() { System.Console.WriteLine("A System.Console.WriteLine( "A message from the static method."); method." ); }

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

posteriores, las expresiones lambda reemplazan a los métodos anónimos como la manera preferente de escribir código insertado. No obstante, la información sobre los métodos anónimos de este tema también se aplica a las expresiones lambda. Hay un caso en el que un método anónimo proporciona una funcionalidad que no se encuentra en las expresiones lambda. Los métodos anónimos permiten omitir l a lista de parámetros, y esto significa que un método anónimo se puede convertir en delegados con diversas firmas. Esto no es posible con expresiones lambda. Para obtener más i nformación sobre las expresiones lambda, vea Expresiones lambda (Guía de programación de C#) . La creación de métodos anónimos es básicamente una forma de pasar un bloque de código como parámetro de delegado. A continuación se describen dos ejemplos de esto:  // Create a handler handler for a click event event button1.Click += delegate delegate(System.Object (System.Object o, System.EventArgs e) { System.Windows.Forms.MessageBox. System.Windows.Forms.MessageBox.Show( Show("Click!" "Click!"); ); };  // Create a delegate delegate instance delegate void Del(int Del(int x);  // Instantiate the delegate delegate using an anonymous anonymous method Del d = delegate delegate((int k) { /* { /* ... */ };

Mediante los métodos anónimos, se reduce la sobrecarga de codificación a la hora de crear instancias de delegados, ya que no es necesario crear un método independiente. Por ejemplo, especificar un bloque de código en vez de un delegado puede ser útil en el caso de que la creación de un método pueda suponer una sobrecarga innecesaria. Un buen ejemplo es cuando se inicia un nuevo subproceso. Esta clase crea un subproceso y también contiene el código que el subproceso ejecuta

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

A diferencia de las variables locales, el período de duración de la variable capturada se extiende hasta que los delegados que hacen referencia a los métodos anónimos cumplan con los requisitos para la recolección de elementos no utilizados. En el momento en que se crea el delegado, se captura el valor de n. Un método anónimo no puede tener acceso a los parámetros ref  ref u u out de un ámbito externo. No se puede obtener acceso a código no seguro dentro del bloque de método anónimo. No se permite el uso de métodos anónimos en el lado l ado izquierdo del operador is is.. Ejemplo

El ejemplo siguiente muestra las dos maneras de crear instancias de un delegado:  

Asociar el delegado a un método anónimo. Asociar el delegado a un método con nombre (DoWork).

En cada uno de los casos, se muestra un mensaje cuando se invoca al delegado.  // Declare a delegate delegate void Printer(string Printer(string s); class TestClass { static void Main() {  // Instatiate the delegate type using using an anonymous method: Printer p = delegate delegate((string j) { System.Console.WriteLine(j);

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

lo que se define en el delegado. La contravarianza permite un método con tipos de pa rámetro que se deriven menos que en el tipo de delegado. Ejemplo 1 (covarianza)

Descripción

Este ejemplo muestra cómo se pueden utilizar los del egados con métodos que tienen tipos de valor devueltos que se derivan del tipo de valor devuelto en la firma fi rma de delegado. El tipo de datos devuelto por SecondHandler es de tipo Dogs, que se deriva del tipo Mammals definido en el delegado. class Mammals { } class Dogs : Mammals { } class Program {

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Este ejemplo muestra cómo se pueden utilizar los del egados con métodos que tienen parámetros de un tipo que son tipos base del tipo t ipo de parámetro de la firma fi rma de delegado. Con la contravarianza, puede utilizar ahora un controlador de eventos en lugares donde anteriormente tenía que utilizar controladores distintos. Por ejemplo, ahora puede crear un controlador de eventos que acepte un parámetro de entrada EventArgs y utilizarlo con el evento Button.MouseClick que envía un ti po MouseEventArgs como parámetro, parámetro, y también con el evento TextBox.KeyDown que envía un parámetro KeyEventArgs. System.DateTime lastActivity; public Form1() { InitializeComponent() lastActivity = new System.DateTime(); this.textBox1.KeyDown this .textBox1.KeyDown += this this.MultiHandler; .MultiHandler; //works  //works with KeyEventArgs KeyEventArgs this.button1.MouseClick this .button1.MouseClick += this this.MultiHandler; .MultiHandler; //works  //works with with MouseEventArgs }

 // Event hander for for any event with an EventArgs EventArgs or  // derived class in the second parameter

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

System.Console.WriteLine("" Hello, {0}!" System.Console.WriteLine( {0}!",, s); } static void Goodbye(string Goodbye(string s) { System.Console.WriteLine("" Goodbye, {0}!" System.Console.WriteLine( {0}!",, s); } static void Main() { Del a, b, c, d;  // Create the delegate object object a that references  // the method Hello: a = Hello;  // Create the delegate object object b that references  // the method Goodbye:

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

public void Notify(int Notify(int i) { } Del d1 = new Del(Notify); En C# 2.0 y versiones posteriores, también es posible utilizar un método anónimo para declarar e inicializar un delegado mediante esta sintaxis simplificada: Del d2 = Notify; En C# 3.0 y versiones posteriores, también es posible declarar delegados y crear instancias de ellos mediante una expresión lambda. Para obtener más información, vea Expresiones lambda (Guía de programación de C#). C#) . El siguiente ejemplo ilustra la declaración, creación de instancias y uso de un delegado. La clase BookDB encapsula una base de datos de los libros de una librería. Expone un método ProcessPaperbackBooks, el cual busca todos los libros en edición rústica de l a base de datos y llama a un delegado para cada uno. El tipo delegate que se utiliza uti liza se denomina ProcessBookDelegate. La clase Test utiliza esta clase para imprimir los títulos y el precio medio de los libros en edición rústica.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

 // Add a book to the database: database: public void AddBook(string AddBook( string title, string author, decimal price, bool paperBack) { list.Add(new list.Add(new Book(title, author, price, paperBack)); paperBack)); }  // Call a passed-in delegate delegate on each paperback paperback book to process it: public void ProcessPaperbackBooks( ProcessPaperbackBooks(ProcessBookDe ProcessBookDelegate legate processBook) { foreach (Book b in list) { if (b.Paperback) if  (b.Paperback)  // Calling the delegate: processBook(b); } } }

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

 // Initialize the database database with some books: AddBooks(bookDB);  // Print all the titles of paperbacks: paperbacks: System.Console.WriteLine("Paperback System.Console.WriteLine( "Paperback Book Titles:"); Titles:" );  // Create a new delegate delegate object associated associated with the static  // method Test.PrintTitle: Test.PrintTitle: bookDB.ProcessPaperbackBooks(PrintTitle);  // Get the average price price of a paperback by using  // a PriceTotaller PriceTotaller object: PriceTotaller totaller = new PriceTotaller();  // Create a new delegate delegate object associated associated with the nonstatic  // method AddBookToTotal AddBookToTotal on the object totaller: bookDB.ProcessPaperbackBook bookDB.ProcessPaperbackBooks(totaller.AddBookTo s(totaller.AddBookToTotal); Total);

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Una vez declarado un tipo delegado, debe crearse un objeto delegado y asociarlo con un determinado método. En el ejemplo anterior, esto se hace p asando el método PrintTitle al método ProcessPaperbackBooks ProcessPaperbackBooks como en el ejemplo siguiente: bookDB.ProcessPaperbackBooks(PrintTitle);

Esto crea un nuevo objeto delegado asociado con el método estático Test.PrintTitle. De igual forma, el método no estático AddBookToTotal del objeto totaller se pasa como en el ejemplo siguiente: bookDB.ProcessPaperbackBoo bookDB.ProcessPaperbackBooks(totaller.AddBookT ks(totaller.AddBookToTotal); oTotal);

En ambos casos, este nuevo objeto delegado se pasa al método ProcessPaperbackBooks. ProcessPaperbackBooks. Una vez que se crea el delegado, el método con el que está asociado no cambia nunca; los objetos

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Tipo: System.Object Origen del evento. e

Tipo: System.EventArgs Clase EventArgs que no contiene datos de evento.

Comentarios

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

datos de evento que no contiene datos. La segunda línea de código del ejemplo define el miembro del evento de la clase para un evento que no tiene datos. public delegate void EventHandler(Object sender, EventArgs e); public event EventHandler NoDataEventHandler;

EventArgs (Clase)

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

public int ferocity; }

//end of class FireEventArgs

// Class with a function that creates the eventargs and initiates the event public class FireAlarm {

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

else if (fe.ferocity < 5) Console.WriteLine("I'm Console.WriteLine("I'm using FireExtinguisher to put out the fire in the { 0}.", 0}." ,

fe.room); else

Console.WriteLine("The Console.WriteLine("The fire in the {0} is out of control. fire department! department!" ", fe.room); } } //end of class FireHandlerClass FireHandlerClass

I'm calling the

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.





 

El editor determina cuándo se produce un evento; los suscriptores determinan qué operación se realiza en respuesta al evento. Un evento puede tener varios suscriptores. Un suscriptor puede controlar varios eventos de varios editores. Nunca se provocan eventos que no tienen suscriptores. Los eventos se suelen usar para señalar acciones del usuario, como hacer clic en un botón o seleccionar un menú en interfaces i nterfaces gráficas de usuario. Si un evento tiene ti ene varios suscriptores, se invocan los controladores de eventos sincrónicamente

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

} }

2. Declare un delegado para el evento. Dé un nombre al delegado EventNameEventHandler. public delegate void AlarmEventHandler(object AlarmEventHandler( object sender, AlarmEventArgs e);

3. Defina un miembro de evento público denominado EventName en la clase. Establezca el tipo del miembro de evento en el tipo de delegado de eventos. public class AlarmClock { ... public event AlarmEventHandler Alarm; }

4. Defina en la clase un método protegido que provoque el evento. Dé un nombre al método OnEventName. Provoque el evento dentro del método. public class AlarmClock { ... public event AlarmHandler Alarm; protected virtual void OnAlarm(Alarm EventArgs e) Alarm(this Alarm(this, , e); } }

{

if (Alarm != null null) )

5. Determine cuándo provocar provocar el evento en la clase. Llame a OnEventName para provocar el evento y pase los datos específicos del evento utilizando EventNameEventArgs. Public Class AlarmClock { ... public void Start() { ... System.Threading.Thread.Sleep(300); AlarmEventArgs e = new AlarmEventArgs(false AlarmEventArgs(false, , 0); OnAlarm(e); } }

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

controla un evento Alarm. La clase AlarmDriver utiliza las clases juntas, estableciendo el método AlarmRang de WakeMeUp para controlar el evento Alarm de AlarmClock. Este programa de ejemplo utiliza conceptos descritos de forma detallada en Eventos y delegados y Provocar un evento. evento.

Ejemplo // EventSample.c EventSample.cs. s. // namespace EventSample { using System; using System.ComponentModel; // Class that contains the data for // the alarm event. Derives from System.EventArgs. // public class AlarmEventArgs : EventArgs { private readonly bool snoozePressed ; private readonly int nrings; //Constructor. // public AlarmEventArgs(bool AlarmEventArgs(bool snoozePressed, int nrings) { this.snoozePressed this .snoozePressed = snoozePressed; this.nrings this .nrings = nrings; } // The NumRings property returns the number of rings // that the alarm clock has sounded when the alarm event // is generated. // public int NumRings { get { return nrings;} } // The SnoozePressed property indicates whether the snooze // button is pressed on the alarm when the alarm event is generated. // public bool SnoozePressed { get {return snoozePressed;} } // The AlarmText property that contains the wake-up message. // public string AlarmText

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

{ return ("Wake Up!"); Up!"); } } } } // Delegate declaration. // public delegate void AlarmEventHandler(object AlarmEventHandler( object sender, AlarmEventArgs e); // The Alarm class that raises the alarm event. // public class AlarmClock { private bool snoozePressed = false false; ; private int nrings = 0; private bool stop = false false; ; // The Stop property indicates whether the // alarm should be turned off. // public bool Stop { get {return stop;} set {stop = value;} } // The SnoozePressed property indicates whether the snooze // button is pressed on the alarm when the alarm event is generated. // public bool SnoozePressed { get {return snoozePressed;} set {snoozePressed = value;} } // The event member that is of type AlarmEventHandler. // public event AlarmEventHandler Alarm; // The protected OnAlarm method raises the event by invoking // the delegates. The sender is always this, the current instance // of the class. // protected virtual void OnAlarm(AlarmEventArgs e) { AlarmEventHandler handler = Alarm; if (handler != null null) ) { // Invokes the delegates. handler(this handler(this, , e); }

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

// the time delay is 1000 milliseconds. // public void Start() { for (;;) { nrings++; if (stop) { break; break ; } else if (snoozePressed) { System.Threading.Thread.Sleep(1000); { AlarmEventArgs e = new AlarmEventArgs(snoozePressed, nrings); OnAlarm(e); } } else { System.Threading.Thread.Sleep(300); AlarmEventArgs AlarmEventArgs e = new AlarmEventArgs(snoozePressed, nrings); OnAlarm(e); } } } } // The WakeMeUp class has a method AlarmRang that handles the // alarm event. // public class WakeMeUp { public void AlarmRang(object AlarmRang(object sender, AlarmEventArgs e) { Console.WriteLine(e.AlarmText +"\n" +"\n"); ); if (!(e.SnoozePressed)) { if (e.NumRings % 10 == 0) { Console.WriteLine(" Console.WriteLine( " Let alarm ring? Enter Y"); Y"); Console.WriteLine(" Console.WriteLine( " Press Snooze? Enter N"); N"); Console.WriteLine(" Console.WriteLine( " Stop Alarm? Enter Q"); Q"); String input = Console.ReadLine(); Console.ReadLine();

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

{ ((AlarmClock)sender).Stop = true true; ; return; return ; } } } else { Console.WriteLine(" Console.WriteLine(" Let alarm ring? Enter Y"); Y"); Console.WriteLine(" Console.WriteLine(" Stop Alarm? Enter Q"); Q"); String input = Console.ReadLine(); if (input.Equals("Y" (input.Equals("Y") ) || input.Equals( input.Equals("y" "y")) )) return return; ; else { ((AlarmClock)sender).Stop = true true; ; return; return ; } } } } // The driver class that hooks up the event handling method of // WakeMeUp to the alarm event of an Alarm object using a delegate. // In a forms-based application, the driver class is the // form. // public class AlarmDriver { public static void Main (string (string[] [] args) { // Instantiates the event receiver. WakeMeUp w= new WakeMeUp(); // Instantiates the event source. AlarmClock clock = new AlarmClock(); // Wires the AlarmRang method to the Alarm event. clock.Alarm += new AlarmEventHandler(w.AlarmRang); clock.Start(); } } }

Provocar múltiples eventos

Si la clase provoca varios eventos y se programan programan como se describe en Provocar un evento, el compilador generará un campo por cada instancia del delegado de evento. Si el número de eventos es alto, es posible que el costo de almacenamiento de un campo

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

campos de evento, ya que se debe obtener cada delegado de evento antes de poder invocarlo. La memoria y la velocidad se ven afectadas. Si la clase define muchos eventos que no se provocan con frecuencia, es posible que desee implementar propiedades de evento. Los controles de formularios Windows Forms y los controles de servidor ASP.NET utilizan propiedades de evento en lugar de campos de evento.

Vea también

Tareas Cómo: Controlar varios eventos mediante propiedades de eventos Cómo: Declarar eventos que evitan que se pierda memoria

Cómo: Controlar varios eventos mediante propiedades de eventos

Para poder utilizar propiedades de evento (eventos personalizados de Visual Basic 2005), hay que definirlas en la clase que provoca los eventos y, a continuación, establecer los delegados de las p ropiedades ropiedades de evento en las clases que controlan los eventos. Para implementar varias propiedades propiedades de evento en una clase, esta clase deberá almacenar internamente y mantener el delegado definido para cada evento. Para hacerlo, uno de los enfoques típicos consiste en implementar una colección de delegados que se indice por medio de una clave de evento. Para almacenar los delegados de cada evento, puede utilizar la clase EventHandlerList o implementar su propia colección. La clase de colección debe proporcionar métodos para establecer, obtener acceso y recuperar el delegado del controlador de eventos basándose en la clave del evento. Por ejemplo, se puede utilizar una clase Hashtable o derivar una clase personalizada a partir de la clase DictionaryBase. No es necesario exponer los detalles de implementación de la colección de delegados fuera de la clase. Cada una de las propiedades de evento de la clase define un método de descriptor descriptor de acceso add y un método de descriptor de acceso remove. El descriptor de acceso add de una propiedad de evento agrega la instancia de delegado de entrada a la colección de delegados. El descriptor de acceso remove de una propiedad de evento elimina la instancia de delegado de entrada de la colección de delegados. Los descriptores de acceso de las propiedades propiedades de eventos utilizan la clave predefinida de la propiedad de evento para agregar y eliminar instancias en la colección de delegados. Para controlar varios eventos mediante las propiedades de evento

1. Defina una colección de delegados dentro de la clase que provoca los eventos. 2. Defina una clave para cada evento.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Nota:

Estas propiedades no se admiten en Visual Basic 2005. // The class SampleControl defines two event properties, MouseUp and MouseDown. class // // //

SampleControl: Component { : Define other control methods and properties. :

// Define the delegate collection. protected EventHandlerList EventHandlerList listEventDelegates = new EventHandlerList(); // Define a unique key for each event. static readonly object mouseDownEventKey = new object object(); (); static readonly object mouseUpEventKey = new object object(); (); // Define the MouseDown event property. public event MouseEventHandler MouseDown { // Add the input delegate to the collection. add { listEventDelegates.AddHandler(mouseDownEventKey, value); } // Remove the input delegate from the collection. remove { listEventDelegates.RemoveHandler(mouseDownEventKey, value); } } // Define the MouseUp event property. public event MouseEventHandler MouseUp { // Add the input delegate to the collection. add { listEventDelegates.AddHandler(mouseUpEventKey, value); } // Remove the input delegate from the collection. remove { listEventDelegates.RemoveHandler(mouseUpEventKey, value); } } }

Cómo: Declarar eventos que evitan que se pierda memoria

Hay varias circunstancias en las que es importante que una aplicación mantenga un bajo uso de memoria. Los eventos

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Cómo: Controlar varios eventos mediante propiedades de eventos

Para poder utilizar propiedades de evento (eventos personalizados de Visual Basic 2005), hay que definirlas en la clase que provoca los eventos y, a continuación, establecer los delegados de las propiedades de evento en las clases que controlan los eventos. Para implementar varias propiedades propiedades de evento en una clase, esta clase deberá almacenar internamente y mantener el delegado definido para cada evento. Para hacerlo, uno de los enfoques típicos consiste en implementar una colección de delegados que se indice por medio de una clave de evento. Para almacenar los delegados de cada evento, puede utilizar la clase EventHandlerList o implementar su propia colección. La clase de colección debe proporcionar métodos para establecer, obtener acceso y recuperar el delegado del controlador de eventos basándose en la clave del evento. Por ejemplo, se puede utilizar una clase Hashtable o derivar una clase personalizada a partir de la clase DictionaryBase. No es necesario exponer los detalles de implementación de la colección de delegados fuera de la clase. Cada una de las propiedades de evento de la clase define un método de descriptor de acceso add y un método de descriptor de acceso remove. El descriptor de acceso add de una propiedad de evento agrega la instancia de delegado de entrada a la colección de delegados. El descriptor de acceso remove de una propiedad de evento elimina la instancia de delegado de entrada de la colección de delegados. Los descriptores de acceso de las propiedades propiedades de eventos utilizan la clave predefinida de la propiedad de evento para agregar y eliminar instancias en la colección de delegados. Para controlar varios eventos mediante las propiedades de evento

1. 2. 3. 4.

Defina una colección de delegados dentro de la clase que provoca los eventos. Defina una clave para cada evento. Defina las propiedades de evento de la clase que provoca los eventos. Utilice la colección de delegados para implementar los métodos de descriptor de acceso add y remove de las propiedades propiedades de evento. 5. Utilice las propiedades de evento públicas para agregar y quitar delegados de controlador de eventos en las clases que controlan los eventos.

Ejemplo

En el siguiente ejemplo de C#, se implementan las propiedades de evento MouseDown y MouseUp mediante el uso de EventHandlerList para almacenar el delegado de cada evento. Las palabras clave de las construcciones construcciones de propiedades de evento están en negrita.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

Trusted by over 1 million members

Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.

static readonly object mouseUpEventKey = new object object(); (); // Define the MouseDown event property. public event MouseEventHandler MouseDown { // Add the input delegate to the collection. add { listEventDelegates.AddHandler(mouseDownEventKey, value); } // Remove the input delegate from the collection. remove { listEventDelegates.RemoveHandler(mouseDownEventKey, value); } } // Define the MouseUp event property. public event MouseEventHandler MouseUp { // Add the input delegate to the collection. add { listEventDelegates.AddHandler(mouseUpEventKey, value); } // Remove the input delegate from the collection. remove { listEventDelegates.RemoveHandler(mouseUpEventKey, value); } } }

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF