Click here to Skip to main content
15,867,986 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
See more:
I have two forms. Both of the forms, I have two lists of strings. From the FORM 1 I have sent two list to FORM 2 by calling the constructor of Form2. In Form 2, I have another 2 lists that gets the copy from lists that have been sent by Form 1.

C#
List<string> SongList = new List<string>();
        List<string> PathList = new List<string>();

        public frmPlayList(List<string> a, List<string> b)
        {
            InitializeComponent();
            SongList = a;
            PathList = b;
        }

Now, if I made any changes to the lists present in Form2 (SongList and PathList).
My question is, if the other lists of Form 1 (that was sent to Form2) will be modified or not??
Posted
Updated 29-Oct-11 13:27pm
v2
Comments
Amir Mahfoozi 30-Oct-11 3:11am    
Yes

1 solution

Unless you reset the reference, it's the same object. So yes, any changes (adding, removing objects) you make are done on the original list objects.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 29-Oct-11 22:04pm    
Correct, a 5.
--SA
Nish Nishant 31-Oct-11 7:33am    
Thanks.
Espen Harlinn 30-Oct-11 9:14am    
5'ed!
Nish Nishant 31-Oct-11 7:33am    
Thanks.

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