I have a class.
public class abc
{
public int i = 0;
public string a = "";
}
=======================================
Now, I am inserting some records in list of type abc class
List<abc> c = new System.Collections.Generic.List<abc>();
abc a = new abc();
a.a = "1";
a.i = 1;
c.Add(a);
a = new abc();
a.a = "1";
a.i = 2;
c.Add(a);
===========================================
Creating a list variable and adding some filtered records.
List<abc> temp = new System.Collections.Generic.List<abc>();
temp.AddRange(c.Where(i => i.i == 1));
===============================================
Query = by executing the below lines of code will change the c variable as well.
I know both points to same memory location. Is there any way to fix this code?
foreach (abc d in temp)
{
d.i = 10;
}