Wrox Programmer Forums
|
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 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 December 3rd, 2010, 03:17 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 101
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?
 
Old April 15th, 2011, 10:45 AM
Wrox Author
 
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
Default

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

Christian
__________________
Christian
CN innovation
Visit my blog at: csharp.christiannagel.com
Follow me on twitter: @christiannagel
 
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









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