Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

C# 3.0 property setter question!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CSharper - 21 Mar 2008 15:45 GMT
I know you can now define something like the follwing

public string Name{set; get;}

during compiling it will create requested information along with the
private varaible to work with. Here is my question; I have a class
called Person and I want to get the values but not setting the value.

public class Person myPerson;
public Person LocalPerson
{

}

in the main window
...

myPerson = new Person
CSharper - 21 Mar 2008 15:51 GMT
> I know you can now define something like the follwing
>
[quoted text clipped - 14 lines]
>
> myPerson = new Person

sorry I didn't complete what I have

public class person myPerson
public Person LocalPerson
{
   set { myPerson = value; }
   get { return myPerson; }
}

.... in the window construct

myPerson = new Person();
...

my question is how can I avoid using myPerson variable and use the
property setter itself. Trying to avoid one variable...
Thanks,
Hans Kesting - 21 Mar 2008 17:15 GMT
CSharper presented the following explanation :
>> I know you can now define something like the follwing
>>
[quoted text clipped - 32 lines]
> property setter itself. Trying to avoid one variable...
> Thanks,

That automatic property is not limited to "basic types", you can use
that on any type:

public Person LocalPerson { get; set; }

or

public Person LocalPerson { get; private set; }

you still need a
LocalPerson = new Person();
somewhere.

Hans Kesting
CSharper - 21 Mar 2008 18:28 GMT
On Mar 21, 11:15 am, Hans Kesting <invalid.han...@spamgourmet.com>
wrote:
> CSharper presented the following explanation :
>
[quoted text clipped - 51 lines]
>
> - Show quoted text -

Excellent, thats what I was looking for

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.