Array Class
Array class is a abstract class so we can not create object for abstract classes so how we create array can you explain the internal process
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Piotr JustynaPosted Dec 1, 2009, 5:29 AM
There's no possibility of creating abstract class object. The only thing you can do is to implement that abstract class and then instanciate the implementing class (of course making sure, that the implementing class is not abstract too :) )
Please mark my answer as helpful if you like it.
Cheers!
srinivasPosted Nov 30, 2009, 10:58 PM
theLizardPosted Nov 26, 2009, 3:37 PM
int[] j = new int[0]; //zero elements
--> Array.Resize(ref j, j.Length +1); //increase size of array by one (1)
This is most useful in while or for loops.
eg.
int i = 0;
while(i != recordCount){
Array.Resize(ref j, j.Length +1);
j[i]= i;
i++;
}
Piotr JustynaPosted Nov 26, 2009, 10:50 AM
Array sampleArray = Array.CreateInstance(Type.GetType("String"), 2);
This will create an instance of an one-dimensional array, which can contain 2 elements of type 'String'. This is 100% correct but it's a lot easier to use this array:
String[] sampleArray1 = new String[2];
String[] sampleArray2 = new String[] { "String 1", "String 2" };
In the first case you create an array with uninitialized elements (both are null) and in the second case sampleArray2 has 2 initialized elements ("String 1" and "String 2"). I hope this will help you.
Cheers!