Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
|
BOOK: Beginning Visual C# 2005
This is the forum to discuss the Wrox book Beginning Visual C# 2005 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780764578472
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 7th, 2006, 01:00 PM
Authorized User
 
Join Date: May 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Absolute Beginers Comprehension of Events

using System;
using System.Collections.Generic;
using System.Text;

namespace BeautyEvents
{
    public delegate void BeautyActionHandler();

    public class Beauty
    {
        public string _name;

        public Beauty(string name)
        {
            _name = name;
        }

        public event BeautyActionHandler TakesBath;

        public void TakingBathHappens()
        {
            if (TakesBath != null)
            {
                Console.WriteLine("{0} is taking a bath.", _name);
                this.TakesBath();
            }
        }



    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace BeautyEvents
{
    public class BathRoom
    {
        public void ShutDoor()
        {
            Console.WriteLine("BothRoom door shut!");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace BeautyEvents
{
    class Program
    {
        static void Main(string[] args)
        {
            Beauty Mary = new Beauty("Mary");
            BathRoom XFBathRoom = new BathRoom();

            Mary.TakesBath += new BeautyActionHandler(XFBathRoom.ShutDoor);
            Mary.TakingBathHappens();

            Console.ReadKey();

        }
    }
}

// 1. Create a delegate
// 2. create an event
// 3. create a method to fire the event.


// 4. Create an event handler in a event handling class.

// 5. Initializing the delegate in the client code.
// 6. Join the the event and the instance of the delegate with the +=
// operator (passing in the event handler method)
// 7. type in the event firing method and run the aplication.






Similar Threads
Thread Thread Starter Forum Replies Last Post
for c# beginers Kalyan Khetre C# 15 July 25th, 2008 05:05 AM
HELP: SQL BEGINERS!!! gijapon_x SQL Server 2005 2 December 1st, 2006 03:52 PM
position: absolute; fix for IE 7 crmpicco Javascript How-To 1 March 30th, 2006 04:45 AM
Absolute position vs. other divs beckfield CSS Cascading Style Sheets 2 March 23rd, 2005 04:21 AM
position:absolute nerssi CSS Cascading Style Sheets 3 February 21st, 2005 10:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.