Click here to Skip to main content
Rate this: bad
good
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 11:57am
Edited 29-Oct-11 14:27pm
v2
Comments
Amir Mahfoozi at 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 at 29-Oct-11 22:04pm
   
Correct, a 5.
--SA
Nishant Sivakumar at 31-Oct-11 7:33am
   
Thanks.
Espen Harlinn at 30-Oct-11 9:14am
   
5'ed!
Nishant Sivakumar at 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
0 OriginalGriff 250
1 George Jonsson 175
2 Jochen Arndt 150
3 Kornfeld Eliyahu Peter 149
4 PIEBALDconsult 110
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 29 Oct 2011
Copyright © CodeProject, 1999-2014
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