Click here to Skip to main content
15,902,845 members
Home / Discussions / C#
   

C#

 
GeneralRe: IComparer Sorting multiple properties. Pin
Vijay Kulavade14-Jan-08 7:23
Vijay Kulavade14-Jan-08 7:23 
Generalput a folder Pin
angels77714-Jan-08 4:35
angels77714-Jan-08 4:35 
GeneralRe: put a folder Pin
Pete O'Hanlon14-Jan-08 5:12
mvePete O'Hanlon14-Jan-08 5:12 
GeneralRe: put a folder Pin
angels77714-Jan-08 14:04
angels77714-Jan-08 14:04 
GeneralRe: put a folder Pin
Pete O'Hanlon14-Jan-08 22:25
mvePete O'Hanlon14-Jan-08 22:25 
GeneralRe: put a folder Pin
DaveyM6914-Jan-08 23:36
professionalDaveyM6914-Jan-08 23:36 
GeneralHttpRequest object for a Web Reference API Pin
Skippums14-Jan-08 4:05
Skippums14-Jan-08 4:05 
QuestionC# readonly reference (like C++ const reference ) Pin
Zeinpresiyo14-Jan-08 3:26
Zeinpresiyo14-Jan-08 3:26 
Hello,
I'd like to export a "List<t> type" field of a class keeping it unmodifiable by accesses "from outside". Exporting a copy of the List could be a solution, but I'd like to do it avoiding the copy operation. I mean,

public class MyClass
{
private List<component> component_list= new List<component>();
public List<component> Component_list
{
get {
//copy operation
List<component> list = new List<component> (component_list);
return list;
}
}
}

Can I get the same behaviour retrieving not a copy but a reference to component_list ?

MyClass obj = new MyClass();
List<component> readonlyListRef = obj.Component_list;
readonlyListRef.Clear();
//I want to avoid this code to clear MyClass' member component_list.

I think that neither "readonly" nor "const" make what i want, because the list can be modified during the execution, not only at the construction-time of the MyClass object.

thanks !
GeneralRe: C# readonly reference (like C++ const reference ) Pin
Justin Perez14-Jan-08 3:45
Justin Perez14-Jan-08 3:45 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
PIEBALDconsult14-Jan-08 4:13
mvePIEBALDconsult14-Jan-08 4:13 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
PIEBALDconsult14-Jan-08 4:18
mvePIEBALDconsult14-Jan-08 4:18 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
DavidNohejl14-Jan-08 4:56
DavidNohejl14-Jan-08 4:56 
AnswerRe: C# readonly reference (like C++ const reference ) Pin
Zeinpresiyo14-Jan-08 6:12
Zeinpresiyo14-Jan-08 6:12 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
Pete O'Hanlon14-Jan-08 9:53
mvePete O'Hanlon14-Jan-08 9:53 
GeneralRe: C# readonly reference (like C++ const reference ) Pin
Zeinpresiyo17-Jan-08 0:04
Zeinpresiyo17-Jan-08 0:04 
Questiondeleting a file in use Pin
Ofori Boadu14-Jan-08 3:06
Ofori Boadu14-Jan-08 3:06 
GeneralRe: deleting a file in use Pin
benjymous14-Jan-08 3:13
benjymous14-Jan-08 3:13 
GeneralRe: deleting a file in use Pin
Ofori Boadu14-Jan-08 3:32
Ofori Boadu14-Jan-08 3:32 
GeneralRe: deleting a file in use Pin
S. Senthil Kumar14-Jan-08 3:21
S. Senthil Kumar14-Jan-08 3:21 
GeneralRe: deleting a file in use Pin
Luc Pattyn14-Jan-08 5:48
sitebuilderLuc Pattyn14-Jan-08 5:48 
QuestionSetting BackColor & ForeColor of each Component Pin
Programm3r14-Jan-08 2:43
Programm3r14-Jan-08 2:43 
GeneralRe: Setting BackColor & ForeColor of each Component Pin
benjymous14-Jan-08 2:53
benjymous14-Jan-08 2:53 
QuestionRe: Setting BackColor & ForeColor of each Component Pin
Programm3r14-Jan-08 2:59
Programm3r14-Jan-08 2:59 
GeneralRe: Setting BackColor & ForeColor of each Component Pin
benjymous14-Jan-08 3:01
benjymous14-Jan-08 3:01 
GeneralRe: Setting BackColor & ForeColor of each Component Pin
Programm3r14-Jan-08 3:07
Programm3r14-Jan-08 3:07 

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.