I have a class EvoObject.cs which has a constructor defined as:
public class EvoObject
{
private Object _id;
private List<List<Int32>> _attributes;
public EvoObject(Object _id, params List<Int32> _args)
{
List<Int32> _attrib = new List<int>();
Debug.Assert(_args.Count >= 2, "Invalid attributes!");
this._id = _id;
_attributes = new List<List<Int32>>(_args.Count);
for (int _i = 0; _i < _args.Count; _i++)
{
_attrib.Add(_args[_i]);
}
_attributes.Add(_attrib);
}
}
in which I have used params for accepting variable number of parameters.
Now I have another method in another class which returns new EvoObject as:
return new EvoObject(_author, _coAuthors, _papers, _venues);
in which I want to relate
_authorwithObject _id_coAuthors,_papers,_venueswithparams List<Int32> _args
in constructor of class EvoObject.cs whereas _coAuthors, _papers and _venues: all are lists of type List<Int32>
I'm getting error at line:
return new EvoObject(_author, _coAuthors, _papers, _venues);
i.e. EvoObject does not contains a constructor that takes 4 arguments.
How params can be useful here?
paramskeyword requires a single dimension array, you can't useList<T>.List<List<Int32>>is going to tell you which identifiers are for what things (papers, venues, etc.). Is that information really not important? What use do those integers become when it's not known what they represent? It seems like some sensible data structures could solve a lot of problems here, including the one being asked.List<List<Int32>the first list will store number of attributes that is 3 for each Object id (i.e._author) and the nested list will store attribute values for each attribute (i.e._papers,_coAuthors,_venues)