Wrox Programmer Forums
|
BOOK: Beginning Visual C# 2010
This is the forum to discuss the Wrox book Beginning Visual C# 2010 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, ; ISBN: 9780470502266
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2010 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 November 24th, 2011, 03:03 PM
Authorized User
 
Join Date: Nov 2011
Posts: 34
Thanks: 14
Thanked 0 Times in 0 Posts
Default Ch13ExO3\Connections

instead :

public class Connection
{
public delegate void messagehandler(Connection source,messagearrivedeventargs e);

public event messagehandler messagearived;
private Timer polltimer;

public string name { get; set; }
......


Can we write this:?


public class Connection
{
public delegate void messagehandler(Connection source,messagearrivedeventargs e);

public event messagehandler messagearived;
private Timer polltimer;

public string name;


private string Name
{
get
{
return Name;
}

set

{
name=Name;
}
}
.............
 
Old November 24th, 2011, 05:18 PM
Wrox Author
 
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
Default

You can write a full property
Code:
private string name;

public string Name
{
  get
  {
    return name;
  }
  set
  {
    name=value;
  }
}
Instead of an automatic property
Code:
public string Name { get; set; }
See page 233 for automatic properties:
...the compiler declares a private field that is used for storage, and uses that field in the get and set blocks of your property....
__________________
Christian
CN innovation
Visit my blog at: csharp.christiannagel.com
Follow me on twitter: @christiannagel
The Following User Says Thank You to ChristianNagel For This Useful Post:
dampyr (November 25th, 2011)
 
Old November 25th, 2011, 02:00 AM
Authorized User
 
Join Date: Nov 2011
Posts: 34
Thanks: 14
Thanked 0 Times in 0 Posts
Default

I forgot that instead:

set
{
name=Name;
}

must be:

set
{
name=value;
}
{
name=value;
}




Currently,all informations are mixed in my head.I must re-read this book at least twice for fully understanding.

Last edited by dampyr; November 25th, 2011 at 02:01 AM.. Reason: adding





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with connections dotnetfreak ASP.NET 1.0 and 1.1 Basics 21 January 18th, 2007 02:07 PM
Database - connections gkn Oracle 0 December 20th, 2005 07:27 AM
Socket connections hockney General .NET 1 July 6th, 2005 04:14 AM
Connections saulodet ADO.NET 2 January 2nd, 2004 04:55 PM





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