AUTHOR
    share
  • USA
  • Member since Jun 15 2010

Bio


Hi, I have a questions about this code block that I was wondering if someone could help me with. I know it works but I'm having trouble making sense of it:

// with this code block, trying to better understand what is happening. First, to make sure I understand my syntax:
// Is it correct that the property(s) are the variables that are PascalCase; and the properties fields are the variables that are camelCase? And, only the property can access
// the field? Here I'm trying to understand why (1) my class constructor is declaring a field member (2) why the field is assigning the
// my property value (3) and then finally the Property is got and set. I guess this would have made more sense
// to me if at (1) the property is declared within the class constructor (2) the associativity was switched
// whereas the Property assigns the field value ''name = Name'', since only the property can directly access the field
class Contact : AddressBook, IListable
{
public Contact(string firstName, string lastName, string address, string phone)
{

FirstName = firstName;
LastName = lastName;
Address = address;
Phone = phone;
}

public string FirstName { get; set;}
public string LastName {get; set;}
public string Address { get; set;}
public string Phone {get; set;}

Recent Posts     Most popular

    No contribution found in last 2 years