Click here to Skip to main content
15,892,674 members
Home / Discussions / C#
   

C#

 
AnswerRe: traversing two lists simultaneously Pin
Gerry Schmitz9-Apr-20 10:57
mveGerry Schmitz9-Apr-20 10:57 
AnswerRe: traversing two lists simultaneously Pin
James Curran13-Apr-20 1:14
James Curran13-Apr-20 1:14 
Question2 Async/Await Questions Pin
Kevin Marois8-Apr-20 18:10
professionalKevin Marois8-Apr-20 18:10 
AnswerRe: 2 Async/Await Questions Pin
Richard Deeming9-Apr-20 0:16
mveRichard Deeming9-Apr-20 0:16 
GeneralRe: 2 Async/Await Questions Pin
Kevin Marois9-Apr-20 6:22
professionalKevin Marois9-Apr-20 6:22 
QuestionGetting Text From External Application Pin
KiriGaya-Rye8-Apr-20 13:09
KiriGaya-Rye8-Apr-20 13:09 
QuestionHow to read/load a certificate stored in a JKS (Java key stores) file format, in .NET (C#) Pin
yuvraj vichare8-Apr-20 5:20
yuvraj vichare8-Apr-20 5:20 
AnswerRe: How to read/load a certificate stored in a JKS (Java key stores) file format, in .NET (C#) Pin
jkirkerx8-Apr-20 9:38
professionaljkirkerx8-Apr-20 9:38 
QuestionBackground Data Tables In C# Pin
Member 133258467-Apr-20 0:21
Member 133258467-Apr-20 0:21 
AnswerRe: Background Data Tables In C# Pin
Gerry Schmitz7-Apr-20 6:52
mveGerry Schmitz7-Apr-20 6:52 
AnswerRe: Background Data Tables In C# Pin
Mycroft Holmes7-Apr-20 11:11
professionalMycroft Holmes7-Apr-20 11:11 
AnswerRe: Background Data Tables In C# Pin
#realJSOP8-Apr-20 5:45
mve#realJSOP8-Apr-20 5:45 
GeneralRe: Background Data Tables In C# Pin
Mycroft Holmes8-Apr-20 13:15
professionalMycroft Holmes8-Apr-20 13:15 
GeneralRe: Background Data Tables In C# Pin
#realJSOP9-Apr-20 3:37
mve#realJSOP9-Apr-20 3:37 
QuestionNeed some tips... Sharing a collection of classes for display in a listbox? Pin
DaveHopeDev14-Apr-20 10:58
DaveHopeDev14-Apr-20 10:58 
AnswerRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Luc Pattyn4-Apr-20 11:57
sitebuilderLuc Pattyn4-Apr-20 11:57 
GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
DaveHopeDev14-Apr-20 22:45
DaveHopeDev14-Apr-20 22:45 
GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Luc Pattyn5-Apr-20 2:11
sitebuilderLuc Pattyn5-Apr-20 2:11 
When you return a collection of objects basically it is an array of pointers. Making the collection read-only protects the array, not its elements (the objects it refers to). So whatever you do, as long as you export instances of Vehicle, they become public and modifiable.

There are two ways to remedy this:

1. Create and export a deep copy: build a new collection with copies of your Vehicles. Now if Vehicle contains references (say to a Manufacturer class), then these objects must be deep copied too. That soon gets very cumbersome.

2. Create and export exactly the information you need, in a data structure that isn't otherwise used in your ParkingLot class. In this case that would be a list of strings. And then you should create this data each time it is requested, you should not store it inside ParkingLot and just pass a pointer, as then one client could still falsify the information another client gets.

Either way, the clean approach is to provide a ParkingLot property or method that creates and returns the information required; and then you can use that any way you want, no harm can be done to the ParkingLot.

The one thing you probably would also need is a way to signal the outside world your ParkingLot has changed. An event seems appropriate here.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
DaveHopeDev15-Apr-20 6:18
DaveHopeDev15-Apr-20 6:18 
GeneralRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Luc Pattyn5-Apr-20 6:21
sitebuilderLuc Pattyn5-Apr-20 6:21 
AnswerRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Mycroft Holmes4-Apr-20 12:41
professionalMycroft Holmes4-Apr-20 12:41 
AnswerRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
Gerry Schmitz5-Apr-20 11:03
mveGerry Schmitz5-Apr-20 11:03 
AnswerRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
BillWoodruff7-Apr-20 0:11
professionalBillWoodruff7-Apr-20 0:11 
AnswerRe: Need some tips... Sharing a collection of classes for display in a listbox? Pin
James Curran7-Apr-20 4:36
James Curran7-Apr-20 4:36 
QuestionFlowlayoutpanel Filter Pin
lakith sandeepa3-Apr-20 20:48
lakith sandeepa3-Apr-20 20:48 

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.