Posts

Single level Inheritance in C#

using  System; namespace  Encapsulation {      class   Program  :  A     {          // Data Members          int  a = 10;          int  b = 20;          static   void  Main( string [] args)         {              // Instanciation              Program  objProgram =  new   Program ();             objProgram.addition();              A  obj =  new  Encapsulation. A ();   ...

Delegates With Examples in C#

Simple Delegates With Examples. Delegates have the following properties: Delegates are similar to C++ function pointers, but are type safe. Delegates allow methods to be passed as parameters. Delegates can be used to define callback methods. Delegates can be chained together; for example, multiple methods can be called on a single event. Methods don't need to match the delegate signature exactly. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code that can call the referenced method, without having to know at compile time which method will be invoked. An interesting and useful property of a delegate is that it does not know or care about the class of the object that it references. Any object will do; all that matters is that the method's argument types and return type match the delegate's. This makes delegates perfectly suited for "anonymous" invocation. ...

C# events and event handlers

Image
What are Events in C#:  In simple terms event means happening or action or occurrence of anything. Event can be anything it can be mouse click, enter key press, lost focus. In other words they are the notification, means something is going to change or ready to happen. Handling of the event is known as response. for example when you click on a button another page opens, here button click is an event and second part is the response of that events.  When events happens a notification sent to client so that client can prepare the response. I am going to explain event handling in a very simple way, let’s suppose you have many objects in your application and they interact with other, now you tell me how you will know which of these many objects has changed their state? Any guess? Yes C sharp has the answer. You can do it by using Event source Event Handler Event Source:  It is responsible to inform other objects that something has changed. Event Handler:  When...