Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
we have Person class where have Public List<person> list { get; set; } Can someone write this code? thank you ;)))
Posted
Comments
CHill60 13-May-14 14:40pm    
I'm sorry we don't write code to order here. Have a go at it yourself and come back if you have a problem. Or post what you have tried so far and explain any problems you are having.
[no name] 13-May-14 15:03pm    
Yes... "someone" can.... *you* can.
Nelek 13-May-14 18:25pm    
Many people can do it, but the right question is... are they going to do it? Problably not.

This is not how CP usually works. Most important goal here is to learn and help learning.
You are supposed to try it on your own, and come here when you got stuck with something, with a concrete question about your code, design, etc.
Please have a look to What have you tried?[^] to see a good explanation about what I mean.
Don't forget people here don't get payed. And besides, if we give you a ready-to-go solution, it is not going to help you because you are not going to learn anything from it.

1 solution

OK:
C#
public List<person> List { get; set; }

Other than that, it's a bad idea to expose a collection directly, and it could use either code in the class constructor to create an empty list by default, or a backing field rather than using an automatic property. I'd also make the setter private.

The rest is up to you: it's your homework, and we do not do your homework - it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

So try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900