what is the Differance between normal property & the property with get ;set;

Posted by Johnseelan under ASP.NET on 10/9/2012 | Points: 10 | Views : 669 | Status : [Member] | Replies : 2
Hi All,

i have a class,

[serviveContract]
public Class Employee
{
[operationContract]
public string Firstname{get;set;}
[operationContract]
public string LastName;
}

or u consider the normal class it is located in business entities console application
i am going to use this class to insert employee value and get the employee details


public Class Employee
{

public string Firstname{get;set;}

public string LastName;

}

my doubt is what is the exact differant between firstname & lastname




Responses

Posted by: Kanje_Ravi on: 10/9/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Johnseelan,


With respect your below query::

public Class Employee
{

public string Firstname{get;set;}

public string LastName;

}


Here are the differences according to my understanding ::
1. FirstName is a property,LastName is not a property but instead it is a member variable.
2. LastName exposes the field directly for manupulation when create new object.(information is exposed here)
3.With the FirstName , you must use the getter and setter and you can add any kind of validation and other logic around these actions and is a best practise.



Thanks & Regards,
Ravindra M
(Success Always Depends on Dedication & Commitment)

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Johnseelan on: 10/9/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks Ravi,

Thanks & regards
John

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response