So i have this struct
public struct Way
{
public Int64 ID;
public List<Int64> Ref; //contains a list with Node IDs
public List<string> Tag;
public List<string> Value;
public Way(Int64 id, List<Int64> refe, List<string> tage, List<string> valuee)
{
ID = id;
Ref = new List<Int64>(refe); //contains a list with Node IDs
Tag = new List<string>(tage);
Value = new List<string>(valuee); // This list is ALWAYS the same lenght as the Tag list
}
};
This struct is used as a base template to store data in retrieved from a large file. So I create a list of this struct to store all the data in.
public List<Way> WayList = new List<Way>();
In the processing algorithm i use a temporary struct to temporarily store each data in while processing the file line by line (data for 1 way can span from 4 lines to 800-1000 lines of text or more).
List<Int64> a = new List<Int64>();
List<string> b = new List<string>();
List<string> c = new List<string>();
Way FoundWay = new Way(0, a, b, c);
I then add this temporary struct into the list with the Add function.
WayList.Add(CopyWay);
In debug mode this is what happens. The temporary struct has the correct data in it. But when i Add this struct into the WayList then this happens:
- the ID gets input by value (each way in the list has an unique ID = good)
- the lists gets input by reference ( each way in the list has the same lists = bad)
my question is, is there a way possible to get these list input by value, or do i need to abandon the use of a struct?