c# - Can't write class with params as property -
it seems can't write class params property. there way set params property class?
for method, can this:
public static void method(double x,params double[] k) { }
i class takes unknown number of arguments.
class:
public class class { double x; params double[] k; }
and create new object
var obj = new class(1d, 1d, 1d, ...); // var obj = new class(1d, new double[] { 1d, 1d, ...}); //this not comfortable!
is there way set params property class?
no, , there no need. can make class constructor accept params double[] doubles
, store them inside array:
void main() { var = new a(1.0, 2.0, 3.0); } public class { private double[] doubles; public a(params double[] doubles) { this.doubles = doubles; } }
Comments
Post a Comment