c# 4.0 - How to fill tuple in C#? -
i have got tuple as:
private tuple<double, double, int>[] circle;
i trired add , element using add()
method. there not exist.
how add element in tuple array?
forget tuples second. how fill any arrays?
private int[] _numbers; // what?
the answer arrays, in c#, have immutable size - must allocated during initialization, , that's size have. once you've initialized them, can assign values array members index:
_numbers = new int[5]; _numbers[0] = 5; circle = new tuple<double,double,int>[5]; circle[0] = new tuple<double,double,int>(1.0, 2.0, 3);
if you're coming in different language , expect variable-length array can added to, you're looking .net's list<t>
class, can initialized empty, , have members added , removed.
private list<tuple<double,double,int>> circle; circle = new list<tuple<double,double,int>>(); circle.add(new tuple<double,double,int>(3.0, 2.0, 1));
Comments
Post a Comment