M
Mike Windsor
This seems like a fairly basic thing to want to to, but as far as I can
tell, it's not possible. Can anyone help?
I have a class 'Foo' and I want to call the constructor with a particular
(identical) value for each object in an array of 'Foo's:
public class Foo
{
public Foo(bool val)
{
// Some code
}
}
....
Foo[] arr1 = new Foo[100](true); // This doesn't work, but it
represents what I want to do
Foo[] arr2 = new Foo(false)[250]; // Likewise...
Is there any way around this, short of defining a new method,
'Initialise(bool val)' and moving the initialisation code to there from the
original constructor?
Thanks for your help.
Cheers,
Mike
tell, it's not possible. Can anyone help?
I have a class 'Foo' and I want to call the constructor with a particular
(identical) value for each object in an array of 'Foo's:
public class Foo
{
public Foo(bool val)
{
// Some code
}
}
....
Foo[] arr1 = new Foo[100](true); // This doesn't work, but it
represents what I want to do
Foo[] arr2 = new Foo(false)[250]; // Likewise...
Is there any way around this, short of defining a new method,
'Initialise(bool val)' and moving the initialisation code to there from the
original constructor?
Thanks for your help.
Cheers,
Mike