I'm passing a list as argument, and creating a second one inside a method, but when I change the second one, the changes are also being applied on the first. Am I missing something?
Appreciate any hint on this
//Creating List method
public List<(string pro_description, DateTime pro_opentimes)> Analysis_simple_FW_ListFW_npos_mposapos(List<(DateTime pro_opentimes, double pro_opencost)> arg_list0, int arg_npos, int arg_mposapos)
{
//The return list
List<(string pro_description, DateTime pro_opentimes)> list1
= new List<(string pro_description, double pro_opencost)>();
//A list to store the arg_list0 that is used as an argument
List<(DateTime pro_opentimes, double pro_opencost)> arg_list1 = arg_list0;
int n2 = arg_list0.Count;
if (n2 > 0)
{
if (arg_list1.Count() > arg_npos * arg_mposapos)
{
//I change here the arg_list1.. hoping only arg_list1 is changed
arg_list1.RemoveRange(0, (arg_list1.Count() / arg_mposapos - arg_npos * arg_mposapos) );
}
if (par_checklive_AnalysisListBar)
{
//I realize here, that arg_list0, in the end, also has entries removed.. Why??
Print("CHECKLIVE: Analysis_simple_FW_ListFW_npos_mposapos( arg_list0.Count:" + arg_list0.Count + " arg_list1.Count:" + arg_list1.Count);
}
list1.Add(("Start: ", arg_list1[0].pro_opencost, dtUTCtoLocal(arg_list1[0].pro_opentimes), 0, 0, (0, 0, 0)));
}
return list1;
}