Click here to Skip to main content
15,905,612 members
Home / Discussions / C#
   

C#

 
QuestionExposing List<> outside class [modified] Pin
Jan Sommer26-Nov-08 2:10
Jan Sommer26-Nov-08 2:10 
AnswerRe: Exposing List<> outside class Pin
leppie26-Nov-08 2:20
leppie26-Nov-08 2:20 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 2:29
Jan Sommer26-Nov-08 2:29 
AnswerRe: Exposing List<> outside class Pin
leppie26-Nov-08 2:45
leppie26-Nov-08 2:45 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 3:00
Jan Sommer26-Nov-08 3:00 
GeneralRe: Exposing List<> outside class Pin
leppie26-Nov-08 3:20
leppie26-Nov-08 3:20 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 3:45
Jan Sommer26-Nov-08 3:45 
AnswerRe: Exposing List<> outside class Pin
Thomas Weller26-Nov-08 3:24
Thomas Weller26-Nov-08 3:24 
Why for heavens sake should this be bad coding practice??

This is the normal way to do it: Declaring a private field and exposing it through a public property. There's no other way to do it right - your teacher is definitely wrong!

There is one concern with this I can think of:
1. The list should be immutable. If so, simply use customers.AsReadOnly() in your get accessor and provide some methods like Add/RemoveCustomer in your Partner class.

Regards
Thomas

www.thomas-weller.de

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.


GeneralRe: Exposing List<> outside class Pin
Alan Balkany26-Nov-08 3:56
Alan Balkany26-Nov-08 3:56 
GeneralRe: Exposing List<> outside class Pin
Jan Sommer26-Nov-08 4:09
Jan Sommer26-Nov-08 4:09 
GeneralRe: Exposing List<> outside class Pin
Thomas Weller26-Nov-08 4:30
Thomas Weller26-Nov-08 4:30 
Questionimplement IDisposable issue Pin
George_George26-Nov-08 1:57
George_George26-Nov-08 1:57 
AnswerRe: implement IDisposable issue Pin
leppie26-Nov-08 2:02
leppie26-Nov-08 2:02 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 2:08
George_George26-Nov-08 2:08 
GeneralRe: implement IDisposable issue Pin
leppie26-Nov-08 2:18
leppie26-Nov-08 2:18 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 2:25
George_George26-Nov-08 2:25 
GeneralRe: implement IDisposable issue Pin
leppie26-Nov-08 2:41
leppie26-Nov-08 2:41 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 3:16
George_George26-Nov-08 3:16 
GeneralRe: implement IDisposable issue Pin
leppie26-Nov-08 3:23
leppie26-Nov-08 3:23 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 3:31
George_George26-Nov-08 3:31 
AnswerRe: implement IDisposable issue Pin
Scott Dorman26-Nov-08 16:18
professionalScott Dorman26-Nov-08 16:18 
GeneralRe: implement IDisposable issue Pin
George_George26-Nov-08 20:58
George_George26-Nov-08 20:58 
GeneralRe: implement IDisposable issue Pin
Scott Dorman27-Nov-08 2:49
professionalScott Dorman27-Nov-08 2:49 
QuestionHow edit my URL on button click Pin
Exelioindia26-Nov-08 1:48
Exelioindia26-Nov-08 1:48 
AnswerRe: How edit my URL on button click Pin
Simon P Stevens26-Nov-08 1:56
Simon P Stevens26-Nov-08 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.