My goal is to create a List of pairs (of ONLY type double). For example: { {1.0,1.1}, {1.2,1.3}, {1.4,1.5}, {...}, {...} } where {1.0,1.1} is List[0], {1.2,1.3} is List[1], {1.4,1.5} is List[2], et cetera.
RATION ERROR
Tuple<double,double> a1 = new Tuple<double,double>(1.0, 1.1);
Tuple<double,double> a2 = new Tuple<double,double>(1.2, 1.3);
Tuple<double,double> a3 = new Tuple<double,double>(1.4, 1.5);
//List< Tuple<double,double> > a4 = new List< Tuple<double, double> >(a1, a2, a3); //ERROR
List< Tuple<double,double> > a5 = new List< Tuple<double, double> >{a1, a2, a3}; //COMPILES
List< Tuple<double,double> > a6 = new List< Tuple<double, double> >(){a1, a2, a3}; //COMPILES
//List< Tuple<double,double> > a7 = new List< Tuple<double, double> >{a1, a2, a3}(); //ERROR
- In a4, a5, a6, and a7, why are the () optional but the {} are not?
- In a4, why can I not use () for instantiating the List<>, considering the () is made for instantiation arguments?
- Does 2. have the same reasoning as the error when trying to instantiate a7?
I know that [] always indicates selecting an element in an array, hence why I didn't try that.
Also, I am aware of ValueTuple but I want compatibility with previous versions of C# and/or .NET (idk the difference) and Tuple is not significantly more amazing than ValueTuple.
params T[] items(paramsdocumentation). With that in mind, how wouldnew List<Tuple<double, double>>(a1, a2, a3)ever work?new List<Tuple<double, double>>(a1, a2, a3)(or whatever items). There is no constructor that takes items in this format.