Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2008 > BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4
This is the forum to discuss the Wrox book Beginning Microsoft Visual C# 2008 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780470191354
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 29th, 2010, 02:27 PM
Authorized User
 
Join Date: Mar 2010
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Default Chapter 19 - page 641 Struct RegisrtationInformation

Hi all,

I have been trying to figure out but still can't get it.

I don't understand this code snippet :

In the RegisrtationInformation.cs file we implement the struct RegistrationInformation :

Code:
  struct RegistrationInformation
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Email { get; set; }
        public string SelectedEvent {get; set;}
    }
Why do we need to add a property to the class _Default in the file Default.aspx.cs ?

Plus I don't get the implementation. Especially the get {.....}
is that an object initialization?

Because concerning the instance creation it should be :

return new RegistrationInformation{....}


Code:
public RegistrationInformation RegistrationInformation
        {
            get
            {
                return new RegistrationInformation()
                {
                    FirstName = textFirstName.Text,
                    LastName = textLastName.Text,
                    Email = textEmail.Text,
                    SelectedEvent = dropDownListEvents.SelectedValue
                };
            }
        }
Why does it work? I am missing something. I don't understand
Does anyone have the answer or a good explanation?
That would be much appreciated!

Bon
  #2 (permalink)  
Old July 29th, 2010, 03:49 PM
Authorized User
 
Join Date: Mar 2010
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Default

Never mind guys I figured it out.

That's just another way to declare an instance of classes or structs since .Net 3.0.
They did it that way because they didn't implement a constructor with parameters during the implementation of the struct.

Sorry for the inconvenience

Bon
 


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
chapter 19 page 660 Cannot Create a New Database Mike_Pliskin BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 4 September 5th, 2010 01:52 PM
Chapter 19 johanyu BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 November 12th, 2007 10:50 AM
Chapter 11, page 623, struct WNDCLASS Nick Y BOOK: Ivor Horton's Beginning Visual C++ 2005 0 July 13th, 2006 05:08 AM
Chapter 19 johanyu BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 2 October 10th, 2004 11:30 PM



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


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