Here is my Class:
public class Information
{
public Tuple<string, string> pair { get; set; }
public double Signal { get; set; }
public double SigmaMove { get; set; }
public DateTime Date { get; set; }
}
Inforamtion A = new Information() {};
I want to use
A.Clone()
but there is no such method?How to Copy a
List<Information> A = B
by value not by reference(Change of A did not influent B, previous solutions in the website do not work .... I tried)?var TodayInformation = YesterdayInformation.Select(o => new Information { pair = o.pair, Signal = o.Signal, SigmaMove = o.SigmaMove, Date = o.Date, }).ToList();
If I copy this way, and suppose pair is also a complicate new
Class
(e.gList<NewClass>
), so doespair = o.pair,
need be modified to guaranteeTodayInformation
is passed by value?When I add a Initializing Constructor in the Class
Information
public class Information { public Tuple<string, string> pair { get; set; } public double Signal { get; set; } public double SigmaMove { get; set; } public DateTime Date { get; set; } public Information(Information Tem) { pair = Tem.pair; Signal = Tem.Signal ; SigmaMove = Tem.SigmaMove; Date = Tem.Date; } }
Then Inforamtion A = new Information(){};
this constructor no longer work, is it becasue of covered by the new Constructor? Then how to remain this constructor?