Click here to Skip to main content
12,395,327 members (69,183 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
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.

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 29-Oct-11 10:57am
Updated 29-Oct-11 13:27pm
v2
Comments
Amir Mahfoozi 30-Oct-11 3:11am
   
Yes

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2
Comments
SAKryukov 29-Oct-11 22:04pm
   
Correct, a 5.
--SA
Nishant Sivakumar 31-Oct-11 7:33am
   
Thanks.
Espen Harlinn 30-Oct-11 9:14am
   
5'ed!
Nishant Sivakumar 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 29 Oct 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100