Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning Visual C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 7th, 2006, 01:00 PM
Authorized User
 
Join Date: May 2006
Location: , , .
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:45 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.