Wrox Programmer Forums
| 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 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
  #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


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





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