S
Sin Jeong-hun
Is there any way to initialize an array of objects without looping
through each elements?
Class A
{
private int PrivateValue;
public A(int a)
{
PrivateValue=a;
}
}
void Main()
{
A[] arrayA=new A[100];
//At this point, A[0]~A[99] are all nulls
foreach(A a in arrayA) {a=new A(0); }
}
I've been using that kind of code. Is there any precise code? Long
time ago, I hoped
A[] arrayA=new A[100](0);
would work, but it didn't.
through each elements?
Class A
{
private int PrivateValue;
public A(int a)
{
PrivateValue=a;
}
}
void Main()
{
A[] arrayA=new A[100];
//At this point, A[0]~A[99] are all nulls
foreach(A a in arrayA) {a=new A(0); }
}
I've been using that kind of code. Is there any precise code? Long
time ago, I hoped
A[] arrayA=new A[100](0);
would work, but it didn't.