Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 4.0 aka C# 2010 > BOOK: Professional C# 4.0 and .NET 4
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional C# 4.0 and .NET 4
This is the forum to discuss the Wrox book Professional C# 4.0 and .NET 4 by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner; ISBN: 9780470502259
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C# 4.0 and .NET 4 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 Display Modes
  #1 (permalink)  
Old December 3rd, 2010, 02:17 AM
Authorized User
Points: 566, Level: 8
Points: 566, Level: 8 Points: 566, Level: 8 Points: 566, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: St. Louis, , .
Posts: 96
Thanks: 0
Thanked 1 Time in 1 Post
Default How is PropertyChangedEventHandler used?

[FONT='Verdana','sans-serif']How is PropertyChangedEventHandler used?[/font]
[FONT='Verdana','sans-serif']Can you tell me what this bit of code in a class' Initalize method does?[/font]
There is a class in the project we are working on that has a private Initialize method. And there is a bit of code in this method that I want to discuss.
But first, let me describe the class. The class is defined as something like this:
public class Skoobie : BaseThingy, ISkoobie

So, that means that the class, “Skoobie” has two parents that it is inheriting from. What are all the implications about this?

Anyway, so the Initalize method is something like this:

private void Initialize()
{
this.PropertyChanged += (o, e) =>
{
If (e != null)
{
// some stuff is done
}

};
}

Now, “PropertyCHanged” is a member of the parent class “BaseThingy” which is defined like this:

publiceventPropertyChangedEventHandler PropertyChanged;
[FONT='Verdana','sans-serif']What is the code [/font]this.PropertyChanged += (o, e) =>... all about? Is it a LINQ thingy?
Reply With Quote
  #2 (permalink)  
Old April 15th, 2011, 10:45 AM
Wrox Author
Points: 1,041, Level: 12
Points: 1,041, Level: 12 Points: 1,041, Level: 12 Points: 1,041, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2010
Location: Austria
Posts: 143
Thanks: 0
Thanked 51 Times in 51 Posts
Default

(o, e) => { //...
is a Lambda expression

Christian
__________________
Christian
CN innovation
Visit my blog at: weblogs.thinktecture.com/cnagel
Follow me on twitter: @christiannagel
Reply With Quote
  #3 (permalink)  
Old May 24th, 2011, 01:34 AM
Authorized User
 
Join Date: Mar 2011
Posts: 17
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Hi Bill,

Is your BaseThingy class implements INotifyPropertyChanged Interface ?
I think it does..

One more thing
PropertyChanged += (o, e) =>

This is a lambda expression that creates:
a Anonymous-Delegate which takes in two parameter (object, PropertyChangedEventArgs)

[Please correct me if i am wrong]

Last edited by MohamedHassanAli; May 24th, 2011 at 01:41 AM. Reason: Forgot to explain the L Expression
Reply With Quote
Reply


Thread Tools
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



All times are GMT -4. The time now is 10:16 PM.


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